53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
|
|
cda "git.loafle.net/commons/di-go/annotation"
|
|
cdr "git.loafle.net/commons/di-go/registry"
|
|
"git.loafle.net/overflow/container-go"
|
|
|
|
// 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()"`
|
|
|
|
RPCWriteChan chan<- *container.RPCNotification `annotation:"@Resource(name='CONTAINER_RPC_WRITE_CHAN')"`
|
|
}
|
|
|
|
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 {
|
|
select {
|
|
case s.RPCWriteChan <- &container.RPCNotification{Method: method, Params: params}:
|
|
default:
|
|
return fmt.Errorf("cannot write to rpcWriteChan")
|
|
}
|
|
|
|
return nil
|
|
}
|