func main() { dbConfigsFile, dbCredentialsFile := dbconfigs.RegisterCommonFlags() flag.Parse() servenv.Init() if *mycnfFile == "" { log.Fatalf("Please specify the path for mycnf file.") } mycnf, err := mysqlctl.ReadMycnf(*mycnfFile) if err != nil { log.Fatalf("Error reading mycnf file %v", *mycnfFile) } dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, *dbConfigsFile, *dbCredentialsFile) if err != nil { log.Warning(err) } mysqld := mysqlctl.NewMysqld(mycnf, dbcfgs.Dba, dbcfgs.Repl) binlogServer := mysqlctl.NewBinlogServer(mysqld) mysqlctl.EnableBinlogServerService(binlogServer, *dbname) proto.RegisterBinlogServer(binlogServer) rpcwrap.RegisterAuthenticated(binlogServer) servenv.OnClose(func() { mysqlctl.DisableBinlogServerService(binlogServer) }) servenv.Run(*port) }
func registerBsonQueryService(agent *tabletmanager.ActionAgent) { if TabletManagerGoRpcService != nil { log.Warningf("RPC service already up %v", TabletManagerGoRpcService) return } TabletManagerGoRpcService = &TabletManager{agent} rpcwrap.RegisterAuthenticated(TabletManagerGoRpcService) }
func (agent *ActionAgent) RegisterQueryService(mysqld *mysqlctl.Mysqld) { if TabletManagerRpcService != nil { log.Warningf("RPC service already up %v", TabletManagerRpcService) return } TabletManagerRpcService = &TabletManager{agent, mysqld} rpcwrap.RegisterAuthenticated(TabletManagerRpcService) }
func RegisterUpdateStreamService(mycnf *Mycnf) { if UpdateStreamRpcService != nil { //log.Warningf("Update Stream service already initialized") return } UpdateStreamRpcService = &UpdateStream{mycnf: mycnf} UpdateStreamRpcService.states = stats.NewStates("UpdateStreamState", []string{ "Disabled", "Enabled", }, time.Now(), DISABLED) rpcwrap.RegisterAuthenticated(UpdateStreamRpcService) }
func RegisterUpdateStreamService(mycnf *Mycnf) { if UpdateStreamRpcService != nil { //relog.Warning("Update Stream service already initialized") return } UpdateStreamRpcService = &UpdateStream{mycnf: mycnf} UpdateStreamRpcService.states = estats.NewStates("", []string{ "Disabled", "Enabled", }, time.Now(), DISABLED) rpcwrap.RegisterAuthenticated(UpdateStreamRpcService) expvar.Publish("UpdateStreamRpcService", estats.StrFunc(func() string { return UpdateStreamRpcService.statsJSON() })) }
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") }
func main() { flag.Parse() servenv.Init() defer servenv.Close() if *mycnfFile == "" { log.Fatalf("Please specify the path for mycnf file.") } mycnf, err := mysqlctl.ReadMycnf(*mycnfFile) if err != nil { log.Fatalf("Error reading mycnf file %v", *mycnfFile) } binlogServer := mysqlctl.NewBinlogServer(mycnf) mysqlctl.EnableBinlogServerService(binlogServer, *dbname) proto.RegisterBinlogServer(binlogServer) rpcwrap.RegisterAuthenticated(binlogServer) servenv.ServeRPC() proc.ListenAndServe(fmt.Sprintf("%v", *port)) mysqlctl.DisableBinlogServerService(binlogServer) }
func init() { tabletmanager.RegisterQueryServices = append(tabletmanager.RegisterQueryServices, func(agent *tabletmanager.ActionAgent) { rpcwrap.RegisterAuthenticated(&TabletManager{agent}) }) }
// StartServer registers the Server for RPCs func StartServer(ts topo.Server) { rpcwrap.RegisterAuthenticated(&VtctlServer{ts}) }
// RegisterAuthenticated registers the server. func RegisterAuthenticated(barnacle Barnacle) { rpcwrap.RegisterAuthenticated(barnacle) }
func init() { vtgate.RegisterVTGates = append(vtgate.RegisterVTGates, func(vtGate *vtgate.VTGate) { rpcwrap.RegisterAuthenticated(&VTGate{vtGate}) }) }
// RegisterBinlogServerService registers the service for serving and stats. func RegisterBinlogServerService(blServer *BinlogServer) { rpcwrap.RegisterAuthenticated(blServer) }
func init() { binlog.RegisterUpdateStreamServices = append(binlog.RegisterUpdateStreamServices, func(updateStream *binlog.UpdateStream) { rpcwrap.RegisterAuthenticated(&UpdateStream{updateStream}) }) }
// RegisterAuthenticated registers the server. func RegisterAuthenticated(vtgate VTGate) { rpcwrap.RegisterAuthenticated(vtgate) }
func init() { tabletserver.SqlQueryRegisterFunctions = append(tabletserver.SqlQueryRegisterFunctions, func(sq *tabletserver.SqlQuery) { rpcwrap.RegisterAuthenticated(&SqlQuery{sq}) }) }
// RegisterAuthenticated registers a variable that satisfies the UpdateStream interface // as an rpc service that requires authentication. func RegisterAuthenticated(service UpdateStream) { rpcwrap.RegisterAuthenticated(service) }
// helper method to register the server (does interface checking) func RegisterAuthenticated(sqlQuery SqlQuery) { rpcwrap.RegisterAuthenticated(sqlQuery) }
// RegisterBinlogServerService registers the service for serving and stats. func RegisterBinlogServerService(blServer *BinlogServer) { rpcwrap.RegisterAuthenticated(blServer) estats.PublishFunc("BinlogServerRpcService", func() string { return blServer.statsJSON() }) }