probe/service/DataClientService.go

62 lines
1.1 KiB
Go
Raw Normal View History

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