container-go/service/ProbeService.go

55 lines
992 B
Go
Raw Normal View History

2018-05-02 10:59:45 +00:00
package service
import (
2018-05-03 06:14:22 +00:00
"fmt"
2018-05-02 10:59:45 +00:00
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
2018-05-03 08:35:13 +00:00
crc "git.loafle.net/commons/rpc-go/client"
2018-05-02 10:59:45 +00:00
// For annotation
_ "git.loafle.net/overflow/commons-go/core/annotation"
)
2018-05-02 11:14:46 +00:00
var ProbeServiceType = reflect.TypeOf((*ProbeService)(nil))
2018-05-02 10:59:45 +00:00
func init() {
2018-05-02 11:14:46 +00:00
cdr.RegisterType(ProbeServiceType)
2018-05-02 10:59:45 +00:00
}
2018-05-02 11:14:46 +00:00
type ProbeService struct {
2018-05-02 10:59:45 +00:00
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
2018-05-03 08:35:13 +00:00
RPCClient *crc.Client `annotation:"@Resource(name='CONTAINER_RPC_CLIENT')"`
2018-05-02 10:59:45 +00:00
}
2018-05-02 11:14:46 +00:00
func (s *ProbeService) InitService() error {
2018-05-03 08:35:13 +00:00
if nil == s.RPCClient {
return fmt.Errorf("RPCClient is not valid")
2018-05-03 06:30:12 +00:00
}
2018-05-02 10:59:45 +00:00
return nil
}
2018-05-02 11:14:46 +00:00
func (s *ProbeService) StartService() error {
2018-05-02 10:59:45 +00:00
return nil
}
2018-05-02 11:14:46 +00:00
func (s *ProbeService) StopService() {
2018-05-02 10:59:45 +00:00
}
2018-05-02 11:14:46 +00:00
func (s *ProbeService) DestroyService() {
2018-05-02 10:59:45 +00:00
}
2018-05-02 11:14:46 +00:00
func (s *ProbeService) Send(method string, params ...interface{}) error {
2018-05-03 08:35:13 +00:00
if err := s.RPCClient.Send(method, params...); nil != err {
2018-05-03 06:14:22 +00:00
return err
}
return nil
2018-05-02 10:59:45 +00:00
}