aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/server.go
diff options
context:
space:
mode:
authorEgon Elbre <egonelbre@gmail.com>2017-08-08 17:08:37 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-08-08 17:08:37 +0800
commite063d538b80d2edfc3c2b374aaee4e38e2145170 (patch)
treefd27b3a044dc674b9c6d3415a1dfca465d846fa5 /rpc/server.go
parent43437806fb49d4ca0b5f6e7599c9871663960b15 (diff)
downloaddexon-e063d538b80d2edfc3c2b374aaee4e38e2145170.tar.gz
dexon-e063d538b80d2edfc3c2b374aaee4e38e2145170.tar.zst
dexon-e063d538b80d2edfc3c2b374aaee4e38e2145170.zip
rpc: fix megacheck warnings
Diffstat (limited to 'rpc/server.go')
-rw-r--r--rpc/server.go29
1 files changed, 6 insertions, 23 deletions
diff --git a/rpc/server.go b/rpc/server.go
index 62b84af34..30c288349 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -29,11 +29,7 @@ import (
"gopkg.in/fatih/set.v0"
)
-const (
- notificationBufferSize = 10000 // max buffered notifications before codec is closed
-
- MetadataApi = "rpc"
-)
+const MetadataApi = "rpc"
// CodecOption specifies which type of messages this codec supports
type CodecOption int
@@ -49,10 +45,9 @@ const (
// NewServer will create a new server instance with no registered handlers.
func NewServer() *Server {
server := &Server{
- services: make(serviceRegistry),
- subscriptions: make(subscriptionRegistry),
- codecs: set.New(),
- run: 1,
+ services: make(serviceRegistry),
+ codecs: set.New(),
+ run: 1,
}
// register a default service which will provide meta information about the RPC service such as the services and
@@ -124,16 +119,6 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {
return nil
}
-// hasOption returns true if option is included in options, otherwise false
-func hasOption(option CodecOption, options []CodecOption) bool {
- for _, o := range options {
- if option == o {
- return true
- }
- }
- return false
-}
-
// serveRequest will reads requests from the codec, calls the RPC callback and
// writes the response to the given codec.
//
@@ -148,13 +133,11 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
- log.Error(fmt.Sprint(string(buf)))
+ log.Error(string(buf))
}
s.codecsMu.Lock()
s.codecs.Remove(codec)
s.codecsMu.Unlock()
-
- return
}()
ctx, cancel := context.WithCancel(context.Background())
@@ -246,7 +229,7 @@ func (s *Server) ServeSingleRequest(codec ServerCodec, options CodecOption) {
// close all codecs which will cancel pending requests/subscriptions.
func (s *Server) Stop() {
if atomic.CompareAndSwapInt32(&s.run, 1, 0) {
- log.Debug(fmt.Sprint("RPC Server shutdown initiatied"))
+ log.Debug("RPC Server shutdown initiatied")
s.codecsMu.Lock()
defer s.codecsMu.Unlock()
s.codecs.Each(func(c interface{}) bool {