From e068cb5bf3f13d1a523f647402d257022b3fd589 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Tue, 20 Oct 2020 16:48:16 +0300 Subject: Fix RPC interface name, remove old rpc_test code --- plugins/rpc/rpc.go | 6 ++-- plugins/rpc/rpc_test.go | 94 ------------------------------------------------- 2 files changed, 3 insertions(+), 97 deletions(-) (limited to 'plugins/rpc') diff --git a/plugins/rpc/rpc.go b/plugins/rpc/rpc.go index c0aa14fa..bd3e3b2e 100644 --- a/plugins/rpc/rpc.go +++ b/plugins/rpc/rpc.go @@ -9,7 +9,7 @@ import ( "net/rpc" ) -type Plugin interface { +type PluginRpc interface { Name() string RpcService() (interface{}, error) } @@ -25,7 +25,7 @@ type services struct { // Service is RPC service. type Service struct { // TODO do we need a pointer here since all receivers are pointers?? - rpc *rpc.Server + rpc *rpc.Server configProvider config.Provider services []services config Config @@ -114,7 +114,7 @@ func (s *Service) Depends() []interface{} { } } -func (s *Service) RpcService(p Plugin) error { +func (s *Service) RpcService(p PluginRpc) error { s.services = append(s.services, services{ service: p.RpcService(), name: p.Name(), diff --git a/plugins/rpc/rpc_test.go b/plugins/rpc/rpc_test.go index 29d10b0e..9ab1e3e8 100644 --- a/plugins/rpc/rpc_test.go +++ b/plugins/rpc/rpc_test.go @@ -1,95 +1 @@ package rpc - -//import ( -// "testing" -// "time" -// -// "github.com/stretchr/testify/assert" -//) -// -//type testService struct{} -// -//func (ts *testService) Echo(msg string, r *string) error { *r = msg; return nil } -// -//func Test_Disabled(t *testing.T) { -// s := &Service{} -// ok, err := s.Init(&Config{Enable: false}, service.NewContainer(nil), nil) -// -// assert.NoError(t, err) -// assert.False(t, ok) -//} -// -//func Test_RegisterNotConfigured(t *testing.T) { -// s := &Service{} -// assert.Error(t, s.Register("test", &testService{})) -// -// client, err := s.Client() -// assert.Nil(t, client) -// assert.Error(t, err) -// assert.Error(t, s.Serve()) -//} -// -//func Test_Enabled(t *testing.T) { -// s := &Service{} -// ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"}, service.NewContainer(nil), nil) -// -// assert.NoError(t, err) -// assert.True(t, ok) -//} -// -//func Test_StopNonServing(t *testing.T) { -// s := &Service{} -// ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"}, service.NewContainer(nil), nil) -// -// assert.NoError(t, err) -// assert.True(t, ok) -// s.Stop() -//} -// -//func Test_Serve_Errors(t *testing.T) { -// s := &Service{} -// ok, err := s.Init(&Config{Enable: true, Listen: "malformed"}, service.NewContainer(nil), nil) -// assert.NoError(t, err) -// assert.True(t, ok) -// -// assert.Error(t, s.Serve()) -// -// client, err := s.Client() -// assert.Nil(t, client) -// assert.Error(t, err) -//} -// -//func Test_Serve_Client(t *testing.T) { -// s := &Service{} -// ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}, service.NewContainer(nil), nil) -// assert.NoError(t, err) -// assert.True(t, ok) -// -// defer s.Stop() -// -// assert.NoError(t, s.Register("test", &testService{})) -// -// go func() { assert.NoError(t, s.Serve()) }() -// time.Sleep(time.Second) -// -// client, err := s.Client() -// assert.NotNil(t, client) -// assert.NoError(t, err) -// -// var resp string -// assert.NoError(t, client.Call("test.Echo", "hello world", &resp)) -// assert.Equal(t, "hello world", resp) -// assert.NoError(t, client.Close()) -//} -// -//func TestSetEnv(t *testing.T) { -// s := &Service{} -// e := env.NewService(map[string]string{}) -// ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}, service.NewContainer(nil), e) -// -// assert.NoError(t, err) -// assert.True(t, ok) -// -// v, _ := e.GetEnv() -// assert.Equal(t, "tcp://localhost:9018", v["RR_RPC"]) -//} -- cgit v1.2.3