probe/service/DiscoveryClientService.go
crusader 92d7926d3f ing
2018-04-17 23:11:13 +09:00

53 lines
1.0 KiB
Go

package service
import (
"context"
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
logging "git.loafle.net/commons/logging-go"
crc "git.loafle.net/commons/rpc-go/client"
// For annotation
_ "git.loafle.net/overflow/commons-go/core/annotation"
)
var DiscoveryClientServiceType = reflect.TypeOf((*DiscoveryClientService)(nil))
func init() {
cdr.RegisterType(DiscoveryClientServiceType)
}
type DiscoveryClientService struct {
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
DiscoveryService *DiscoveryService `annotation:"@Inject()"`
EncryptionKey string
client *crc.Client
}
func (s *DiscoveryClientService) InitService() error {
return nil
}
func (s *DiscoveryClientService) StartService() error {
return nil
}
func (s *DiscoveryClientService) StopService() {
if nil != s.client {
if err := s.client.Stop(context.Background()); nil != err {
logging.Logger().Error(err)
}
}
}
func (s *DiscoveryClientService) DestroyService() {
s.client = nil
}