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