Ejemplo n.º 1
0
// RegisterAuthenticated registers a receiver with the authenticated
// rpc server.
func RegisterAuthenticated(rcvr interface{}) error {
	// TODO(szopa): This should be removed after the transition
	// period, when all the clients know about authentication.
	if err := rpc.Register(rcvr); err != nil {
		return err
	}
	return AuthenticatedServer.Register(rcvr)
}
Ejemplo n.º 2
0
// 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)
	}
}
Ejemplo n.º 3
0
func main() {
	flag.Parse()
	servenv.Init("vt_binlog_server")

	binlogServer := new(BinlogServer)
	if *mycnfFile == "" {
		relog.Fatal("Please specify the path for mycnf file.")
	}
	mycnf, err := mysqlctl.ReadMycnf(*mycnfFile)
	if err != nil {
		relog.Fatal("Error reading mycnf file %v", *mycnfFile)
	}
	binlogServer.mycnf = mycnf

	binlogServer.dbname = strings.ToLower(strings.TrimSpace(*dbname))
	binlogServer.blpStats = NewBlpStats()

	rpc.Register(binlogServer)
	rpcwrap.RegisterAuthenticated(binlogServer)
	//bsonrpc.ServeAuthRPC()

	rpc.HandleHTTP()
	bsonrpc.ServeHTTP()
	bsonrpc.ServeRPC()

	umgmt.SetLameDuckPeriod(30.0)
	umgmt.SetRebindDelay(0.01)
	umgmt.AddStartupCallback(func() {
		umgmt.StartHttpServer(fmt.Sprintf(":%v", *port))
	})
	umgmt.AddStartupCallback(func() {
		c := make(chan os.Signal, 1)
		signal.Notify(c, syscall.SIGTERM)
		go func() {
			for sig := range c {
				umgmt.SigTermHandler(sig)
			}
		}()
	})

	relog.Info("vt_binlog_server registered at port %v", *port)
	umgmtSocket := fmt.Sprintf("/tmp/vt_binlog_server-%08x-umgmt.sock", *port)
	if umgmtErr := umgmt.ListenAndServe(umgmtSocket); umgmtErr != nil {
		relog.Error("umgmt.ListenAndServe err: %v", umgmtErr)
	}
	relog.Info("done")
}
Ejemplo n.º 4
0
func main() {
	port := flag.Int("port", 9279, "server port")
	flag.Parse()
	arith := new(Arith)
	rpc.Register(arith)

	http.Handle("/_bson_rpc_", &rpcHandler{})
	http.Handle("/shutdown", &shutdownHandler{})
	addr := fmt.Sprintf("localhost:%d", *port)
	var e error
	l, e = net.Listen("tcp", addr)
	if e != nil {
		log.Fatal("listen error:", e)
	}
	log.Printf("arithserver running on %s", addr)
	http.Serve(l, nil)
}
Ejemplo n.º 5
0
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)
	}
	if ServiceMap["bsonrpc-auth-vt-"+name] {
		log.Infof("Registering %v for SASL bsonrpc over vt port, disable it with -bsonrpc-auth-vt-%v service_map parameter", name, name)
		rpcwrap.AuthenticatedServer.Register(rcvr)
	} else {
		log.Infof("Not registering %v for SASL bsonrpc over vt port, enable it with bsonrpc-auth-vt-%v service_map parameter", name, name)
	}

	// register the other guys
	secureRegister(name, rcvr)
}
Ejemplo n.º 6
0
// RegisterBinlogServer makes sure the server implements the right API
func RegisterBinlogServer(server BinlogServer) {
	rpc.Register(server)
}
Ejemplo n.º 7
0
func init() {
	rpcplus.Register(new(Arith))
}
Ejemplo n.º 8
0
// helper method to register the server (does interface checking)
func RegisterZkReader(zkReader ZkReader) {
	rpc.Register(zkReader)
}
Ejemplo n.º 9
0
// RegisterTopoReader register the provided TopoReader for RPC
func RegisterTopoReader(tr TopoReader) {
	rpc.Register(tr)
}