summaryrefslogtreecommitdiff
path: root/plugins/rpc
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-05 15:45:18 +0300
committerValery Piashchynski <[email protected]>2020-11-05 15:45:18 +0300
commitbca69d968ef76a6260956bc169cb07996fbb7724 (patch)
treebcca677f40d0dd19da5095bfe8dc5c6bacf64566 /plugins/rpc
parent3a0a0190ed130e72ebc150bbb3e3c1582f22dd16 (diff)
App test
Diffstat (limited to 'plugins/rpc')
-rwxr-xr-xplugins/rpc/plugin.go (renamed from plugins/rpc/rpc.go)15
-rw-r--r--plugins/rpc/tests/plugin2.go3
2 files changed, 7 insertions, 11 deletions
diff --git a/plugins/rpc/rpc.go b/plugins/rpc/plugin.go
index 5203fc65..6401c0e2 100755
--- a/plugins/rpc/rpc.go
+++ b/plugins/rpc/plugin.go
@@ -5,11 +5,10 @@ import (
"net/rpc"
"sync/atomic"
- "go.uber.org/zap"
-
"github.com/spiral/endure"
"github.com/spiral/errors"
"github.com/spiral/goridge/v2"
+ "github.com/spiral/roadrunner/v2/log"
"github.com/spiral/roadrunner/v2/plugins/config"
)
@@ -22,12 +21,12 @@ type Pluggable interface {
}
// ServiceName contains default service name.
-const ServiceName = "rpc"
+const ServiceName = "RPC"
// Plugin is RPC service.
type Plugin struct {
cfg Config
- log *zap.Logger
+ log log.Logger
rpc *rpc.Server
services []Pluggable
listener net.Listener
@@ -35,7 +34,7 @@ type Plugin struct {
}
// Init rpc service. Must return true if service is enabled.
-func (s *Plugin) Init(cfg config.Configurer, log *zap.Logger) error {
+func (s *Plugin) Init(cfg config.Configurer, log log.Logger) error {
const op = errors.Op("RPC Init")
if !cfg.Has(ServiceName) {
return errors.E(op, errors.Disabled)
@@ -92,7 +91,7 @@ func (s *Plugin) Serve() chan error {
return errCh
}
- s.log.Debug("Started RPC service", zap.String("address", s.cfg.Listen), zap.Any("services", services))
+ s.log.Debug("Started RPC service", "address", s.cfg.Listen, "services", services)
go func() {
for {
@@ -100,11 +99,11 @@ func (s *Plugin) Serve() chan error {
if err != nil {
if atomic.LoadUint32(s.closed) == 1 {
// just log and continue, this is not a critical issue, we just called Stop
- s.log.Error("listener accept error, connection closed", zap.Error(err))
+ s.log.Error("listener accept error, connection closed", "error", err)
return
}
- s.log.Error("listener accept error", zap.Error(err))
+ s.log.Error("listener accept error", "error", err)
errCh <- errors.E(errors.Op("listener accept"), errors.Serve, err)
return
}
diff --git a/plugins/rpc/tests/plugin2.go b/plugins/rpc/tests/plugin2.go
index 2a0ae1a8..854bf097 100644
--- a/plugins/rpc/tests/plugin2.go
+++ b/plugins/rpc/tests/plugin2.go
@@ -1,7 +1,6 @@
package tests
import (
- "fmt"
"net"
"net/rpc"
"time"
@@ -38,8 +37,6 @@ func (p2 *Plugin2) Serve() chan error {
errCh <- err
return
}
- fmt.Println("--------------")
- fmt.Println(ret)
if ret != "Hello, username: Valery" {
errCh <- errors.E("wrong response")
return