ing
This commit is contained in:
parent
4da07c417b
commit
f073163bf7
|
@ -1,16 +1,46 @@
|
||||||
package client
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"path"
|
||||||
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
crr "git.loafle.net/commons_go/rpc/registry"
|
crr "git.loafle.net/commons_go/rpc/registry"
|
||||||
|
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
|
||||||
oopcc "git.loafle.net/overflow/overflow_probe_container/client"
|
oopcc "git.loafle.net/overflow/overflow_probe_container/client"
|
||||||
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(addr string, rpcInvoker crr.RPCInvoker) crc.Client {
|
func New(port int, rpcInvoker crr.RPCInvoker) crc.Client {
|
||||||
ch := oopcc.NewClientHandler(rpcInvoker)
|
addr := fmt.Sprintf("localhost:%d", port)
|
||||||
socketHandler := NewSocketHandler()
|
|
||||||
|
|
||||||
c := oopcc.New(addr, ch, socketHandler)
|
c := oopcc.New(addr, rpcInvoker)
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetContainerCommand(name string) (cmd *exec.Cmd, pidPath string) {
|
||||||
|
pidPath = path.Join(config.Config.Paths["root"], ooccp.PathPID, name+".pid")
|
||||||
|
|
||||||
|
switch name {
|
||||||
|
case ooccp.ContainerGeneralName:
|
||||||
|
javaPath := path.Join(config.Config.Paths["root"], ooccp.PathJRE, "bin", "java")
|
||||||
|
jarPath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerGeneralFileName)
|
||||||
|
// arg := fmt.Sprintf("-jar %s %s", jarPath, pidPath)
|
||||||
|
|
||||||
|
cmd = exec.Command(javaPath, "-jar", jarPath, pidPath)
|
||||||
|
case ooccp.ContainerNetworkName:
|
||||||
|
exePath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerNetworkFileName)
|
||||||
|
arg := fmt.Sprintf("-pid-path=%s", pidPath)
|
||||||
|
|
||||||
|
cmd = exec.Command(exePath, arg)
|
||||||
|
case ooccp.ContainerDiscoveryName:
|
||||||
|
exePath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerDiscoveryFileName)
|
||||||
|
arg := fmt.Sprintf("-pid-path=%s", pidPath)
|
||||||
|
|
||||||
|
cmd = exec.Command(exePath, arg)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package client
|
|
||||||
|
|
||||||
import (
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
|
||||||
crr "git.loafle.net/commons_go/rpc/registry"
|
|
||||||
oopcc "git.loafle.net/overflow/overflow_probe_container/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ClientHandlers struct {
|
|
||||||
oopcc.ClientHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ch *ClientHandlers) Init(clientCTX crc.ClientContext) error {
|
|
||||||
|
|
||||||
return ch.ClientHandler.Init(clientCTX)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ch *ClientHandlers) Destroy(clientCTX crc.ClientContext) {
|
|
||||||
ch.ClientHandler.Destroy(clientCTX)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ch *ClientHandlers) Validate() {
|
|
||||||
ch.ClientHandler.Validate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClientHandler(rpcInvoker crr.RPCInvoker) oopcc.ClientHandler {
|
|
||||||
ch := &ClientHandlers{}
|
|
||||||
ch.ClientHandler = oopcc.NewClientHandler(rpcInvoker)
|
|
||||||
return ch
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package client
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
|
|
||||||
csc "git.loafle.net/commons_go/server/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SocketHandlers struct {
|
|
||||||
csc.SocketHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnConnect(socketContext csc.SocketContext, conn net.Conn) {
|
|
||||||
// no op
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) OnDisconnect(soc csc.Socket) {
|
|
||||||
// no op
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *SocketHandlers) Validate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSocketHandler() csc.SocketHandler {
|
|
||||||
return &SocketHandlers{}
|
|
||||||
}
|
|
22
commons/annotation/service.go
Normal file
22
commons/annotation/service.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package annotation
|
||||||
|
|
||||||
|
// @Service()
|
||||||
|
// inherit @Component
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
cda "git.loafle.net/commons_go/di/annotation"
|
||||||
|
cdia "git.loafle.net/commons_go/di/injection/annotation"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ServiceTag = "@overFlow:Service"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cda.RegisterAnnotation(ServiceTag, reflect.TypeOf((*Service)(nil)))
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
cdia.Component
|
||||||
|
}
|
|
@ -9,9 +9,6 @@
|
||||||
"key": "95d8bcdc739741dca74c4a0e489e0774"
|
"key": "95d8bcdc739741dca74c4a0e489e0774"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"bin": "/bin",
|
|
||||||
"config": "/config",
|
|
||||||
"pid": "/pid",
|
|
||||||
"root": "/project/overFlow/probe"
|
"root": "/project/overFlow/probe"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,3 +7,4 @@ import:
|
||||||
version: v2.17.08
|
version: v2.17.08
|
||||||
- package: github.com/dgrijalva/jwt-go
|
- package: github.com/dgrijalva/jwt-go
|
||||||
version: v3.1.0
|
version: v3.1.0
|
||||||
|
- package: git.loafle.net/commons_go/di
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||||
oopccd "git.loafle.net/overflow/overflow_probes/client/central/data"
|
oopccd "git.loafle.net/overflow/overflow_probes/client/central/data"
|
||||||
oopccp "git.loafle.net/overflow/overflow_probes/client/central/probe"
|
oopccp "git.loafle.net/overflow/overflow_probes/client/central/probe"
|
||||||
"git.loafle.net/overflow/overflow_probes/service"
|
oopca "git.loafle.net/overflow/overflow_probes/commons/annotation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() ProbeManager {
|
func New() ProbeManager {
|
||||||
|
@ -45,23 +45,13 @@ func (pm *probeManagers) Start() error {
|
||||||
}
|
}
|
||||||
cdr.RegisterResource("CentralClients", centralClients)
|
cdr.RegisterResource("CentralClients", centralClients)
|
||||||
|
|
||||||
centralService := service.GetService("CentralService").(*service.CentralService)
|
services := cdr.GetInstancesByAnnotationName(oopca.ServiceTag)
|
||||||
configService := service.GetService("ConfigService").(*service.ConfigService)
|
|
||||||
crawlerService := service.GetService("CrawlerService").(*service.CrawlerService)
|
|
||||||
discoveryService := service.GetService("DiscoveryService").(*service.DiscoveryService)
|
|
||||||
logService := service.GetService("LogService").(*service.LogService)
|
|
||||||
probeService := service.GetService("ProbeService").(*service.ProbeService)
|
|
||||||
sensorService := service.GetService("SensorService").(*service.SensorService)
|
|
||||||
|
|
||||||
probeRPCRegistry.RegisterService(centralService, "")
|
for _, s := range services {
|
||||||
probeRPCRegistry.RegisterService(configService, "")
|
probeRPCRegistry.RegisterService(s, "")
|
||||||
probeRPCRegistry.RegisterService(crawlerService, "")
|
}
|
||||||
probeRPCRegistry.RegisterService(discoveryService, "")
|
|
||||||
probeRPCRegistry.RegisterService(logService, "")
|
|
||||||
probeRPCRegistry.RegisterService(probeService, "")
|
|
||||||
probeRPCRegistry.RegisterService(sensorService, "")
|
|
||||||
|
|
||||||
logging.Logger().Debug(fmt.Sprintf("%v", centralService.CentralClients))
|
// logging.Logger().Debug(fmt.Sprintf("%v", centralService.CentralClients))
|
||||||
|
|
||||||
if err := centralProbeClient.Connect(); nil != err {
|
if err := centralProbeClient.Connect(); nil != err {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -9,10 +9,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*CentralService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*CentralService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type CentralService struct {
|
type CentralService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
|
|
||||||
CentralClients map[string]oogwc.Client `annotation:"@Resource()"`
|
CentralClients map[string]oogwc.Client `annotation:"@Resource()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*ConfigService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*ConfigService)(nil)))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigService struct {
|
type ConfigService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,25 +4,23 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cda "git.loafle.net/commons_go/di/annotation"
|
cda "git.loafle.net/commons_go/di/annotation"
|
||||||
cdr "git.loafle.net/commons_go/di/registry"
|
cdr "git.loafle.net/commons_go/di/registry"
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
crc "git.loafle.net/commons_go/rpc/client"
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
oopcc "git.loafle.net/overflow/overflow_probe_container/client"
|
"git.loafle.net/overflow/overflow_probes/client/container"
|
||||||
"git.loafle.net/overflow/overflow_probes/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*ContainerService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*ContainerService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerService struct {
|
type ContainerService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
|
|
||||||
clients map[string]*containerState
|
clients map[string]*containerState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,33 +69,33 @@ func (cs *ContainerService) runProcess(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdPath := path.Join(config.Config.Paths["root"], config.Config.Paths["bin"], name+".sh")
|
// cmd, pidPath := container.GetContainerCommand(name)
|
||||||
pidPath := path.Join(config.Config.Paths["root"], config.Config.Paths["pid"], name+".pid")
|
// if err := cmd.Start(); nil != err {
|
||||||
|
// logging.Logger().Error(fmt.Sprintf("Probe: To run container(%s) failed err %v", name, err))
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
cmd := exec.Command(cmdPath, pidPath)
|
// port, err := watchPidFileCreate(pidPath, time.Duration(time.Second*2))
|
||||||
if err := cmd.Start(); nil != err {
|
// if nil != err {
|
||||||
logging.Logger().Error(fmt.Sprintf("Probe: To run container(%s) failed err %v", name, err))
|
// return err
|
||||||
return err
|
// }
|
||||||
}
|
port := 60000
|
||||||
|
|
||||||
port, err := watchPidFileCreate(pidPath, time.Duration(time.Second*2))
|
client := container.New(port, nil)
|
||||||
if nil != err {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
clientAddr := fmt.Sprintf("localhost:%d", port)
|
|
||||||
client := oopcc.New(clientAddr, nil)
|
|
||||||
if err := client.Connect(); nil != err {
|
if err := client.Connect(); nil != err {
|
||||||
cmd.Process.Kill()
|
// cmd.Process.Kill()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cState := &containerState{
|
cState := &containerState{
|
||||||
pid: cmd.Process.Pid,
|
pid: 29694,
|
||||||
port: port,
|
port: port,
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nil == cs.clients {
|
||||||
|
cs.clients = make(map[string]*containerState, 0)
|
||||||
|
}
|
||||||
cs.clients[name] = cState
|
cs.clients[name] = cState
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -128,9 +126,12 @@ func (cs *ContainerService) killProcess(name string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.Kill(); nil != err {
|
if err = p.Signal(os.Interrupt); nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// if err = p.Kill(); nil != err {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
69
service/ContainerService_test.go
Normal file
69
service/ContainerService_test.go
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
lfcc "git.loafle.net/commons_go/config"
|
||||||
|
crc "git.loafle.net/commons_go/rpc/client"
|
||||||
|
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
|
||||||
|
"git.loafle.net/overflow/overflow_probes/config"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func initConfig() {
|
||||||
|
dir, err := lfcc.ABSPathify("../")
|
||||||
|
if nil != err {
|
||||||
|
panic("Config path is not valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
config.ConfigDir = &dir
|
||||||
|
|
||||||
|
cfp := path.Join(*config.ConfigDir, ooccp.ConfigFileName)
|
||||||
|
config.ConfigFilePath = &cfp
|
||||||
|
|
||||||
|
conf := lfcc.New()
|
||||||
|
config.Config = &ooccp.Config{}
|
||||||
|
if err := conf.Load(config.Config, *config.ConfigFilePath); nil != err {
|
||||||
|
panic(fmt.Sprintf("Config is not valid: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetClient(t *testing.T) {
|
||||||
|
initConfig()
|
||||||
|
|
||||||
|
cs := GetService("ContainerService").(*ContainerService)
|
||||||
|
|
||||||
|
var c crc.Client
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// // General
|
||||||
|
// c, err = cs.GetClient(ooccp.ContainerGeneralName)
|
||||||
|
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
// assert.NotNil(t, c)
|
||||||
|
|
||||||
|
// err = cs.killProcess(ooccp.ContainerGeneralName)
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
|
||||||
|
// Network
|
||||||
|
c, err = cs.GetClient(ooccp.ContainerNetworkName)
|
||||||
|
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.NotNil(t, c)
|
||||||
|
|
||||||
|
cs.killProcess(ooccp.ContainerNetworkName)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
// // Discovery
|
||||||
|
// c, err = cs.GetClient(ooccp.ContainerDiscoveryName)
|
||||||
|
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
// assert.NotNil(t, c)
|
||||||
|
|
||||||
|
// cs.killProcess(ooccp.ContainerDiscoveryName)
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
|
||||||
|
}
|
|
@ -9,10 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*CrawlerService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*CrawlerService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type CrawlerService struct {
|
type CrawlerService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CrawlerService) Install() error {
|
func (cs *CrawlerService) Install() error {
|
||||||
|
|
|
@ -11,10 +11,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*DiscoveryService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*DiscoveryService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiscoveryService struct {
|
type DiscoveryService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
|
|
||||||
ContainerService *ContainerService `annotation:"@Inject()"`
|
ContainerService *ContainerService `annotation:"@Inject()"`
|
||||||
CentralService *CentralService `annotation:"@Inject()"`
|
CentralService *CentralService `annotation:"@Inject()"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*LogService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*LogService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogService struct {
|
type LogService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LogService) Send() error {
|
func (ls *LogService) Send() error {
|
||||||
|
|
|
@ -8,10 +8,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*ProbeService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*ProbeService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProbeService struct {
|
type ProbeService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *ProbeService) Start() error {
|
func (ps *ProbeService) Start() error {
|
||||||
|
|
|
@ -9,10 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdr.RegisterType(reflect.TypeOf((*SensorService)(nil)), &cda.ComponentAnnotation{})
|
cdr.RegisterType(reflect.TypeOf((*SensorService)(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type SensorService struct {
|
type SensorService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *SensorService) Start(id int64) error {
|
func (ss *SensorService) Start(id int64) error {
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
cdr "git.loafle.net/commons_go/di/registry"
|
|
||||||
"git.loafle.net/commons_go/logging"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitService() {
|
func InitService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,34 +7,34 @@ func DestroyService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetService(name string) interface{} {
|
// func GetService(name string) interface{} {
|
||||||
var t reflect.Type
|
// var t reflect.Type
|
||||||
switch name {
|
// switch name {
|
||||||
case "CentralService":
|
// case "CentralService":
|
||||||
t = reflect.TypeOf((*CentralService)(nil))
|
// t = reflect.TypeOf((*CentralService)(nil))
|
||||||
case "ConfigService":
|
// case "ConfigService":
|
||||||
t = reflect.TypeOf((*ConfigService)(nil))
|
// t = reflect.TypeOf((*ConfigService)(nil))
|
||||||
case "ContainerService":
|
// case "ContainerService":
|
||||||
t = reflect.TypeOf((*ContainerService)(nil))
|
// t = reflect.TypeOf((*ContainerService)(nil))
|
||||||
case "CrawlerService":
|
// case "CrawlerService":
|
||||||
t = reflect.TypeOf((*CrawlerService)(nil))
|
// t = reflect.TypeOf((*CrawlerService)(nil))
|
||||||
case "DiscoveryService":
|
// case "DiscoveryService":
|
||||||
t = reflect.TypeOf((*DiscoveryService)(nil))
|
// t = reflect.TypeOf((*DiscoveryService)(nil))
|
||||||
case "LogService":
|
// case "LogService":
|
||||||
t = reflect.TypeOf((*LogService)(nil))
|
// t = reflect.TypeOf((*LogService)(nil))
|
||||||
case "ProbeService":
|
// case "ProbeService":
|
||||||
t = reflect.TypeOf((*ProbeService)(nil))
|
// t = reflect.TypeOf((*ProbeService)(nil))
|
||||||
case "SensorService":
|
// case "SensorService":
|
||||||
t = reflect.TypeOf((*SensorService)(nil))
|
// t = reflect.TypeOf((*SensorService)(nil))
|
||||||
default:
|
// default:
|
||||||
logging.Logger().Panic(fmt.Sprintf("Probe: Service[%s] is not exist", name))
|
// logging.Logger().Panic(fmt.Sprintf("Probe: Service[%s] is not exist", name))
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
i, err := cdr.GetInstance(t)
|
// i, err := cdr.GetInstance(t)
|
||||||
if nil != err {
|
// if nil != err {
|
||||||
logging.Logger().Panic(fmt.Sprintf("Probe: Getting Service[%s] is failed %v", name, err))
|
// logging.Logger().Panic(fmt.Sprintf("Probe: Getting Service[%s] is failed %v", name, err))
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
return i
|
// return i
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user