2018-04-19 06:24:45 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2018-04-19 13:46:49 +00:00
|
|
|
"fmt"
|
2018-04-19 06:24:45 +00:00
|
|
|
"reflect"
|
|
|
|
|
|
|
|
cda "git.loafle.net/commons/di-go/annotation"
|
|
|
|
cdr "git.loafle.net/commons/di-go/registry"
|
2018-04-19 14:07:14 +00:00
|
|
|
"git.loafle.net/overflow/container-go"
|
2018-04-19 06:24:45 +00:00
|
|
|
|
|
|
|
// For annotation
|
|
|
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ProbeServiceType = reflect.TypeOf((*ProbeService)(nil))
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cdr.RegisterType(ProbeServiceType)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProbeService struct {
|
|
|
|
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
2018-04-19 13:01:11 +00:00
|
|
|
|
2018-04-19 14:07:14 +00:00
|
|
|
RPCWriteChan chan<- *container.RPCNotification `annotation:"@Resource(name='CONTAINER_RPC_WRITE_CHAN')"`
|
2018-04-19 06:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProbeService) InitService() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProbeService) StartService() error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProbeService) StopService() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProbeService) DestroyService() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProbeService) Send(method string, params ...interface{}) error {
|
2018-04-19 13:46:49 +00:00
|
|
|
select {
|
2018-04-19 14:07:14 +00:00
|
|
|
case s.RPCWriteChan <- &container.RPCNotification{Method: method, Params: params}:
|
2018-04-19 13:46:49 +00:00
|
|
|
default:
|
|
|
|
return fmt.Errorf("cannot write to rpcWriteChan")
|
|
|
|
}
|
2018-04-19 06:24:45 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|