probe/service/DataClientService.go
crusader 14a9b28ed2 ing
2018-04-26 17:43:40 +09:00

62 lines
1.1 KiB
Go

package service
import (
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
ocsp "git.loafle.net/overflow/commons-go/service/probe"
"git.loafle.net/overflow/probe/client/central"
// For annotation
_ "git.loafle.net/overflow/commons-go/core/annotation"
)
var DataClientServiceType = reflect.TypeOf((*DataClientService)(nil))
func init() {
cdr.RegisterType(DataClientServiceType)
}
type DataClientService struct {
ocsp.DataClientService
RPCClientService
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
}
func (s *DataClientService) InitService() error {
if err := s.RPCClientService.InitService(); nil != err {
return err
}
return nil
}
func (s *DataClientService) StartService() error {
if err := s.RPCClientService.StartService(); nil != err {
return err
}
client, err := central.NewData()
if nil != err {
return err
}
s.client = client
if err := s.client.Start(); nil != err {
return err
}
return nil
}
func (s *DataClientService) StopService() {
s.RPCClientService.StopService()
}
func (s *DataClientService) DestroyService() {
s.RPCClientService.DestroyService()
}