49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
|
|
cdr "git.loafle.net/commons_go/di/registry"
|
|
"git.loafle.net/commons_go/logging"
|
|
)
|
|
|
|
func InitService() {
|
|
}
|
|
|
|
func DestroyService() {
|
|
|
|
}
|
|
|
|
func GetService(name string) interface{} {
|
|
var t reflect.Type
|
|
switch name {
|
|
case "CentralService":
|
|
t = reflect.TypeOf((*CentralService)(nil))
|
|
case "ConfigService":
|
|
t = reflect.TypeOf((*ConfigService)(nil))
|
|
case "ContainerService":
|
|
t = reflect.TypeOf((*ContainerService)(nil))
|
|
case "CrawlerService":
|
|
t = reflect.TypeOf((*CrawlerService)(nil))
|
|
case "DiscoveryService":
|
|
t = reflect.TypeOf((*DiscoveryService)(nil))
|
|
case "LogService":
|
|
t = reflect.TypeOf((*LogService)(nil))
|
|
case "ProbeService":
|
|
t = reflect.TypeOf((*ProbeService)(nil))
|
|
case "SensorService":
|
|
t = reflect.TypeOf((*SensorService)(nil))
|
|
default:
|
|
logging.Logger().Panic(fmt.Sprintf("Probe: Service[%s] is not exist", name))
|
|
return nil
|
|
}
|
|
|
|
i, err := cdr.GetInstance(t)
|
|
if nil != err {
|
|
logging.Logger().Panic(fmt.Sprintf("Probe: Getting Service[%s] is failed %v", name, err))
|
|
return nil
|
|
}
|
|
return i
|
|
}
|