probe/service/RPCClientService.go
crusader d2d34699aa ing
2018-04-18 23:56:13 +09:00

46 lines
932 B
Go

package service
import (
"context"
"fmt"
"git.loafle.net/commons/logging-go"
crc "git.loafle.net/commons/rpc-go/client"
)
type RPCClientService struct {
client *crc.Client
}
func (s *RPCClientService) InitService() error {
return nil
}
func (s *RPCClientService) StartService() error {
return nil
}
func (s *RPCClientService) StopService() {
if err := s.client.Stop(context.Background()); nil != err {
logging.Logger().Error(err)
}
}
func (s *RPCClientService) DestroyService() {
s.client = nil
}
func (s *RPCClientService) Call(result interface{}, method string, params ...interface{}) error {
if nil == s.client {
return fmt.Errorf("rpc client is not valid")
}
return s.client.Call(result, method, params...)
}
func (s *RPCClientService) Send(method string, params ...interface{}) error {
if nil == s.client {
return fmt.Errorf("rpc client is not valid")
}
return s.client.Send(method, params...)
}