forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.go
31 lines (27 loc) · 1002 Bytes
/
rpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package servenv
import (
log "github.com/golang/glog"
rpc "github.com/youtube/vitess/go/rpcplus"
"github.com/youtube/vitess/go/rpcwrap/bsonrpc"
)
// Register registers a bsonrpc service according to serviceMap
func Register(name string, rcvr interface{}) {
if serviceMap["bsonrpc-vt-"+name] {
log.Infof("Registering %v for bsonrpc over vt port, disable it with -bsonrpc-vt-%v service_map parameter", name, name)
rpc.Register(rcvr)
} else {
log.Infof("Not registering %v for bsonrpc over vt port, enable it with bsonrpc-vt-%v service_map parameter", name, name)
}
}
// ServeRPC will deal with bson rpc serving
func ServeRPC() {
// rpc.HandleHTTP registers the default GOB handler at /_goRPC_
// and the debug RPC service at /debug/rpc (it displays a list
// of registered services and their methods).
if serviceMap["gob-vt"] {
log.Infof("Registering GOB handler and /debug/rpc URL for vt port")
rpc.HandleHTTP()
}
// and register the regular bsonrpc too.
bsonrpc.ServeRPC()
}