-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.go
36 lines (30 loc) · 1020 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
32
33
34
35
36
package servenv
import (
"flag"
log "github.com/golang/glog"
// rpc "github.com/youtube/vitess/go/rpcplus"
"github.com/youtube/vitess/go/rpcwrap/auth"
"github.com/youtube/vitess/go/rpcwrap/bsonrpc"
)
var (
authConfig = flag.String("auth-credentials", "", "name of file containing auth credentials")
)
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).
// So disabling this, but leaving a trace here so it's easy
// to re-add for a quick test on which service is running.
//
// rpc.HandleHTTP()
// if we have an authentication config, we register the authenticated
// bsonrpc services.
if *authConfig != "" {
if err := auth.LoadCredentials(*authConfig); err != nil {
log.Fatalf("could not load authentication credentials, not starting rpc servers: %v", err)
}
bsonrpc.ServeAuthRPC()
}
// and register the regular bsonrpc too.
bsonrpc.ServeRPC()
}