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

49 lines
964 B
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 GeneralClientServiceType = reflect.TypeOf((*GeneralClientService)(nil))
func init() {
cdr.RegisterType(GeneralClientServiceType)
}
type GeneralClientService struct {
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
EncryptionKey string
client *crc.Client
}
func (s *GeneralClientService) InitService() error {
return nil
}
func (s *GeneralClientService) StartService() error {
return nil
}
func (s *GeneralClientService) StopService() {
if nil != s.client {
if err := s.client.Stop(context.Background()); nil != err {
logging.Logger().Error(err)
}
}
}
func (s *GeneralClientService) DestroyService() {
s.client = nil
}