当前位置: 首页>>代码示例>>Golang>>正文


Golang servenv.OnRun函数代码示例

本文整理汇总了Golang中github.com/youtube/vitess/go/vt/servenv.OnRun函数的典型用法代码示例。如果您正苦于以下问题:Golang OnRun函数的具体用法?Golang OnRun怎么用?Golang OnRun使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OnRun函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	servenv.OnRun(func() {
		if servenv.GRPCCheckServiceMap("throttler") {
			StartServer(servenv.GRPCServer, throttler.GlobalManager)
		}
	})
}
开发者ID:CowLeo,项目名称:vitess,代码行数:7,代码来源:grpcthrottlerserver.go

示例2: init

func init() {
	servenv.OnRun(func() {
		if *allowedReplicationLag > 0 {
			health.Register("replication_reporter", mysqlctl.MySQLReplicationLag(agent.Mysqld, *allowedReplicationLag))
		}
	})
}
开发者ID:chinna1986,项目名称:vitess,代码行数:7,代码来源:health.go

示例3: init

func init() {
	servenv.OnRun(func() {
		servenv.AddStatusPart("Topology Cache", topoTemplate, func() interface{} {
			return resilientSrvTopoServer.CacheStatus()
		})
	})
}
开发者ID:kingpro,项目名称:vitess,代码行数:7,代码来源:status.go

示例4: init

func init() {
	servenv.OnRun(func() {
		servenv.AddStatusPart("Tablet", tabletTemplate, func() interface{} {
			return map[string]interface{}{
				"Tablet":            agent.Tablet(),
				"BlacklistedTables": agent.BlacklistedTables(),
			}
		})
		if agent.IsRunningHealthCheck() {
			servenv.AddStatusFuncs(template.FuncMap{
				"github_com_youtube_vitess_health_html_name": healthHTMLName,
			})
			servenv.AddStatusPart("Health", healthTemplate, func() interface{} {
				return &healthStatus{Records: agent.History.Records()}
			})
		}
		tabletserver.AddStatusPart()
		servenv.AddStatusPart("Binlog Player", binlogTemplate, func() interface{} {
			return agent.BinlogPlayerMap.Status()
		})
		if onStatusRegistered != nil {
			onStatusRegistered()
		}
	})
}
开发者ID:nangong92t,项目名称:go_src,代码行数:25,代码来源:status.go

示例5: init

func init() {
	servenv.OnRun(func() {
		if *disableActiveReparents {
			return
		}

		addCommand("Tablets", command{
			"DemoteMaster",
			commandDemoteMaster,
			"<tablet alias>",
			"Demotes a master tablet."})
		addCommand("Tablets", command{
			"ReparentTablet",
			commandReparentTablet,
			"<tablet alias>",
			"Reparent a tablet to the current master in the shard. This only works if the current slave position matches the last known reparent action."})

		addCommand("Shards", command{
			"InitShardMaster",
			commandInitShardMaster,
			"[-force] [-wait_slave_timeout=<duration>] <keyspace/shard> <tablet alias>",
			"Sets the initial master for a shard. Will make all other tablets in the shard slaves of the provided master. WARNING: this could cause data loss on an already replicating shard. PlannedReparentShard or EmergencyReparentShard should be used instead."})
		addCommand("Shards", command{
			"PlannedReparentShard",
			commandPlannedReparentShard,
			"-keyspace_shard=<keyspace/shard> [-new_master=<tablet alias>] [-avoid_master=<tablet alias>]",
			"Reparents the shard to the new master, or away from old master. Both old and new master need to be up and running."})
		addCommand("Shards", command{
			"EmergencyReparentShard",
			commandEmergencyReparentShard,
			"-keyspace_shard=<keyspace/shard> -new_master=<tablet alias>",
			"Reparents the shard to the new master. Assumes the old master is dead and not responsding."})
	})
}
开发者ID:dumbunny,项目名称:vitess,代码行数:34,代码来源:reparent.go

示例6: init

func init() {
	servenv.OnRun(func() {
		if servenv.GRPCCheckServiceMap("vtctl") {
			grpcvtctlserver.StartServer(servenv.GRPCServer, ts)
		}
	})
}
开发者ID:CowLeo,项目名称:vitess,代码行数:7,代码来源:plugin_grpcvtctlserver.go

示例7: main

func main() {
	defer exit.Recover()

	flag.Parse()
	servenv.Init()

	if initFakeZK != nil {
		initFakeZK()
	}
	ts := topo.GetServer()
	defer topo.CloseServers()

	resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")

	healthCheck = discovery.NewHealthCheck(*connTimeoutTotal, *healthCheckRetryDelay, *healthCheckTimeout, "" /* statsSuffix */)

	tabletTypes := make([]topodatapb.TabletType, 0, 1)
	if len(*tabletTypesToWait) != 0 {
		for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
			tt, err := topoproto.ParseTabletType(ttStr)
			if err != nil {
				log.Errorf("unknown tablet type: %v", ttStr)
				continue
			}
			tabletTypes = append(tabletTypes, tt)
		}
	}
	vtg := vtgate.Init(context.Background(), healthCheck, ts, resilientSrvTopoServer, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, tabletTypes, *maxInFlight, *testGateway)

	servenv.OnRun(func() {
		addStatusParts(vtg)
	})
	servenv.RunDefault()
}
开发者ID:aaijazi,项目名称:vitess,代码行数:34,代码来源:vtgate.go

示例8: main

func main() {
	defer exit.Recover()

	flag.Parse()
	servenv.Init()

	ts := topo.GetServer()
	defer topo.CloseServers()

	resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")

	healthCheck = discovery.NewHealthCheck(*healthCheckConnTimeout, *healthCheckRetryDelay, *healthCheckTimeout)
	healthCheck.RegisterStats()

	tabletTypes := make([]topodatapb.TabletType, 0, 1)
	if len(*tabletTypesToWait) != 0 {
		for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
			tt, err := topoproto.ParseTabletType(ttStr)
			if err != nil {
				log.Errorf("unknown tablet type: %v", ttStr)
				continue
			}
			tabletTypes = append(tabletTypes, tt)
		}
	}
	l2vtg := l2vtgate.Init(healthCheck, ts, resilientSrvTopoServer, *cell, *retryCount, tabletTypes)

	servenv.OnRun(func() {
		addStatusParts(l2vtg)
	})
	servenv.RunDefault()
}
开发者ID:jmptrader,项目名称:vitess,代码行数:32,代码来源:main.go

示例9: init

func init() {
	// Wait until flags are parsed, so we can check which topo server is in use.
	servenv.OnRun(func() {
		if etcdServer, ok := topo.GetServer().Impl.(*etcdtopo.Server); ok {
			vtctld.HandleExplorer("etcd", etcdtopo.NewExplorer(etcdServer))
		}
	})
}
开发者ID:littleyang,项目名称:vitess,代码行数:8,代码来源:plugin_etcdtopo.go

示例10: init

func init() {
	servenv.ServiceMap["grpc-mysqlctl"] = true
	servenv.OnRun(func() {
		if servenv.GRPCCheckServiceMap("mysqlctl") {
			grpcmysqlctlserver.StartServer(servenv.GRPCServer, mysqld)
		}
	})
}
开发者ID:pengmingde,项目名称:vitess,代码行数:8,代码来源:plugin_grpcmysqlctlserver.go

示例11: init

func init() {
	servenv.RegisterGRPCFlags()
	servenv.OnRun(func() {
		if servenv.GRPCCheckServiceMap("vtworker") {
			grpcvtworkerserver.StartServer(servenv.GRPCServer, wi)
		}
	})
}
开发者ID:CowLeo,项目名称:vitess,代码行数:8,代码来源:plugin_grpcvtworkerserver.go

示例12: init

func init() {
	// Wait until flags are parsed, so we can check which topo server is in use.
	servenv.OnRun(func() {
		if zkServer, ok := topo.GetServer().Impl.(*zktopo.Server); ok {
			HandleExplorer("zk", "/zk/", "zk.html", NewZkExplorer(zkServer.GetZConn()))
		}
	})
}
开发者ID:richarwu,项目名称:vitess,代码行数:8,代码来源:plugin_zktopo.go

示例13: init

func init() {
	servenv.InitServiceMap("grpc", "mysqlctl")
	servenv.OnRun(func() {
		if servenv.GRPCCheckServiceMap("mysqlctl") {
			grpcmysqlctlserver.StartServer(servenv.GRPCServer, mysqld)
		}
	})
}
开发者ID:littleyang,项目名称:vitess,代码行数:8,代码来源:plugin_grpcmysqlctlserver.go

示例14: main

func main() {
	defer exit.Recover()

	flag.Parse()
	servenv.Init()

	if initFakeZK != nil {
		initFakeZK()
	}
	ts := topo.GetServer()
	defer topo.CloseServers()

	var schema *planbuilder.Schema
	if *schemaFile != "" {
		var err error
		if schema, err = planbuilder.LoadFile(*schemaFile); err != nil {
			log.Error(err)
			exit.Return(1)
		}
		log.Infof("v3 is enabled: loaded schema from file: %v", *schemaFile)
	} else {
		ctx := context.Background()
		schemaJSON, err := ts.GetVSchema(ctx)
		if err != nil {
			log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
			goto startServer
		}
		schema, err = planbuilder.NewSchema([]byte(schemaJSON))
		if err != nil {
			log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
			goto startServer
		}
		log.Infof("v3 is enabled: loaded schema from topo")
	}

startServer:
	resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")

	healthCheck = discovery.NewHealthCheck(*connTimeoutTotal, *healthCheckRetryDelay, *healthCheckTimeout, "" /* statsSuffix */)

	tabletTypes := make([]topodatapb.TabletType, 0, 1)
	if len(*tabletTypesToWait) != 0 {
		for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
			tt, err := topoproto.ParseTabletType(ttStr)
			if err != nil {
				log.Errorf("unknown tablet type: %v", ttStr)
				continue
			}
			tabletTypes = append(tabletTypes, tt)
		}
	}
	vtg := vtgate.Init(healthCheck, ts, resilientSrvTopoServer, schema, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, tabletTypes, *maxInFlight, *testGateway)

	servenv.OnRun(func() {
		addStatusParts(vtg)
	})
	servenv.RunDefault()
}
开发者ID:Rastusik,项目名称:vitess,代码行数:58,代码来源:vtgate.go

示例15: init

func init() {
	servenv.OnRun(func() {
		if !*enableQueries {
			return
		}

		addCommandGroup(queriesGroupName)

		// VtGate commands
		addCommand(queriesGroupName, command{
			"VtGateExecute",
			commandVtGateExecute,
			"-server <vtgate> [-bind_variables <JSON map>] [-connect_timeout <connect timeout>] [-keyspace <default keyspace>] [-tablet_type <tablet type>] [-json] <sql>",
			"Executes the given SQL query with the provided bound variables against the vtgate server."})
		addCommand(queriesGroupName, command{
			"VtGateExecuteShards",
			commandVtGateExecuteShards,
			"-server <vtgate> -keyspace <keyspace> -shards <shard0>,<shard1>,... [-bind_variables <JSON map>] [-connect_timeout <connect timeout>] [-tablet_type <tablet type>] [-json] <sql>",
			"Executes the given SQL query with the provided bound variables against the vtgate server. It is routed to the provided shards."})
		addCommand(queriesGroupName, command{
			"VtGateExecuteKeyspaceIds",
			commandVtGateExecuteKeyspaceIds,
			"-server <vtgate> -keyspace <keyspace> -keyspace_ids <ks1 in hex>,<k2 in hex>,... [-bind_variables <JSON map>] [-connect_timeout <connect timeout>] [-tablet_type <tablet type>] [-json] <sql>",
			"Executes the given SQL query with the provided bound variables against the vtgate server. It is routed to the shards that contain the provided keyspace ids."})
		addCommand(queriesGroupName, command{
			"VtGateSplitQuery",
			commandVtGateSplitQuery,
			"-server <vtgate> -keyspace <keyspace> [-split_column <split_column>] -split_count <split_count> [-bind_variables <JSON map>] [-connect_timeout <connect timeout>] <sql>",
			"Executes the SplitQuery computation for the given SQL query with the provided bound variables against the vtgate server (this is the base query for Map-Reduce workloads, and is provided here for debug / test purposes)."})

		// VtTablet commands
		addCommand(queriesGroupName, command{
			"VtTabletExecute",
			commandVtTabletExecute,
			"[-bind_variables <JSON map>] [-connect_timeout <connect timeout>] [-transaction_id <transaction_id>] [-tablet_type <tablet_type>] [-json] -keyspace <keyspace> -shard <shard> <tablet alias> <sql>",
			"Executes the given query on the given tablet."})
		addCommand(queriesGroupName, command{
			"VtTabletBegin",
			commandVtTabletBegin,
			"[-connect_timeout <connect timeout>] [-tablet_type <tablet_type>] -keyspace <keyspace> -shard <shard> <tablet alias>",
			"Starts a transaction on the provided server."})
		addCommand(queriesGroupName, command{
			"VtTabletCommit",
			commandVtTabletCommit,
			"[-connect_timeout <connect timeout>] [-tablet_type <tablet_type>] -keyspace <keyspace> -shard <shard> <tablet alias> <transaction_id>",
			"Commits a transaction on the provided server."})
		addCommand(queriesGroupName, command{
			"VtTabletRollback",
			commandVtTabletRollback,
			"[-connect_timeout <connect timeout>] [-tablet_type <tablet_type>] -keyspace <keyspace> -shard <shard> <tablet alias> <transaction_id>",
			"Rollbacks a transaction on the provided server."})
		addCommand(queriesGroupName, command{
			"VtTabletStreamHealth",
			commandVtTabletStreamHealth,
			"[-count <count, default 1>] [-connect_timeout <connect timeout>] <tablet alias>",
			"Executes the StreamHealth streaming query to a vttablet process. Will stop after getting <count> answers."})
	})
}
开发者ID:jmptrader,项目名称:vitess,代码行数:58,代码来源:query.go


注:本文中的github.com/youtube/vitess/go/vt/servenv.OnRun函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。