probe/service/DataClientService.go
crusader ca823a2e69 ing
2018-05-03 20:24:07 +09:00

63 lines
1.4 KiB
Go

package service
import (
"fmt"
"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/data"
// 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 fmt.Errorf("DataClientService: InitService failed %v", err)
}
return nil
}
func (s *DataClientService) StartService() error {
if err := s.RPCClientService.StartService(); nil != err {
return fmt.Errorf("DataClientService: StartService failed %v", err)
}
client, err := data.New()
if nil != err {
return fmt.Errorf("ProbeClientService: StartService failed %v", err)
}
s.client = client
if err := s.client.Start(); nil != err {
return fmt.Errorf("DataClientService: StartService failed %v", err)
}
return nil
}
func (s *DataClientService) StopService() {
s.RPCClientService.StopService()
}
func (s *DataClientService) DestroyService() {
s.RPCClientService.DestroyService()
}