本文整理匯總了Golang中github.com/youtube/vitess/go/vt/servenv.RunDefault函數的典型用法代碼示例。如果您正苦於以下問題:Golang RunDefault函數的具體用法?Golang RunDefault怎麽用?Golang RunDefault使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RunDefault函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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()
}
示例2: main
func main() {
flag.Parse()
args := flag.Args()
installSignalHandlers()
servenv.Init()
defer servenv.Close()
ts := topo.GetServer()
defer topo.CloseServers()
// the logger will be replaced when we start a job
wr = wrangler.New(logutil.NewConsoleLogger(), ts, 30*time.Second, 30*time.Second)
if len(args) == 0 {
// interactive mode, initialize the web UI to chose a command
initInteractiveMode()
} else {
// single command mode, just runs it
runCommand(args)
}
initStatusHandling()
servenv.RunDefault()
}
示例3: 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()
}
示例4: 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()
}
示例5: main
func main() {
defer exit.Recover()
defer logutil.Flush()
dbconfigs.RegisterFlags()
flag.Parse()
mycnf := mysqlctl.NewMycnf(uint32(*tabletUid), *mysqlPort)
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Errorf("%v", err)
exit.Return(255)
}
mysqld = mysqlctl.NewMysqld("Dba", mycnf, &dbcfgs.Dba, &dbcfgs.Repl)
// Register OnTerm handler before mysqld starts, so we get notified if mysqld
// dies on its own without us (or our RPC client) telling it to.
mysqldTerminated := make(chan struct{})
mysqld.OnTerm(func() {
close(mysqldTerminated)
})
// Start or Init mysqld as needed.
if _, err = os.Stat(mycnf.DataDir); os.IsNotExist(err) {
log.Infof("mysql data dir (%s) doesn't exist, initializing", mycnf.DataDir)
mysqld.Init(*waitTime, *bootstrapArchive, *skipSchema)
} else {
log.Infof("mysql data dir (%s) already exists, starting without init", mycnf.DataDir)
mysqld.Start(*waitTime)
}
servenv.Init()
defer servenv.Close()
// Take mysqld down with us on SIGTERM before entering lame duck.
servenv.OnTerm(func() {
log.Infof("mysqlctl received SIGTERM, shutting down mysqld first")
mysqld.Shutdown(false, 0)
})
// Start RPC server and wait for SIGTERM.
mysqlctldTerminated := make(chan struct{})
go func() {
servenv.RunDefault()
close(mysqlctldTerminated)
}()
select {
case <-mysqldTerminated:
log.Infof("mysqld shut down on its own, exiting mysqlctld")
case <-mysqlctldTerminated:
log.Infof("mysqlctld shut down gracefully")
}
}
示例6: main
// zkocc: a proxy for zk
func main() {
flag.Parse()
servenv.Init()
zkr := zkocc.NewZkReader(*resolveLocal, flag.Args())
zk.RegisterZkReader(zkr)
servenv.Register("toporeader", &TopoReader{zkr: zkr})
servenv.RunDefault()
}
示例7: main
func main() {
defer exit.Recover()
// flag parsing
flags := dbconfigs.AppConfig | dbconfigs.DbaConfig |
dbconfigs.FilteredConfig | dbconfigs.ReplConfig
dbconfigs.RegisterFlags(flags)
mysqlctl.RegisterFlags()
flag.Parse()
if len(flag.Args()) > 0 {
flag.Usage()
log.Errorf("vtcombo doesn't take any positional arguments")
exit.Return(1)
}
// register topo server
topo.RegisterServer("fakezk", zktopo.NewServer(fakezk.NewConn()))
ts := topo.GetServerByName("fakezk")
servenv.Init()
// database configs
mycnf, err := mysqlctl.NewMycnfFromFlags(0)
if err != nil {
log.Errorf("mycnf read failed: %v", err)
exit.Return(1)
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, flags)
if err != nil {
log.Warning(err)
}
mysqld := mysqlctl.NewMysqld("Dba", "App", mycnf, &dbcfgs.Dba, &dbcfgs.App.ConnParams, &dbcfgs.Repl)
// tablets configuration and init
binlog.RegisterUpdateStreamService(mycnf)
initTabletMap(ts, *topology, mysqld, dbcfgs, mycnf)
// vtgate configuration and init
resilientSrvTopoServer := vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
healthCheck := discovery.NewHealthCheck(30*time.Second /*connTimeoutTotal*/, 1*time.Millisecond /*retryDelay*/)
vtgate.Init(healthCheck, ts, resilientSrvTopoServer, nil /*schema*/, cell, 1*time.Millisecond /*retryDelay*/, 2 /*retryCount*/, 30*time.Second /*connTimeoutTotal*/, 10*time.Second /*connTimeoutPerConn*/, 365*24*time.Hour /*connLife*/, 0 /*maxInFlight*/, "" /*testGateway*/)
servenv.OnTerm(func() {
// FIXME(alainjobart) stop vtgate, all tablets
// qsc.DisallowQueries()
// agent.Stop()
})
servenv.OnClose(func() {
// We will still use the topo server during lameduck period
// to update our state, so closing it in OnClose()
topo.CloseServers()
})
servenv.RunDefault()
}
示例8: main
func main() {
dbconfigs.RegisterFlags()
mysqlctl.RegisterFlags()
flag.Parse()
if len(flag.Args()) > 0 {
flag.Usage()
log.Fatalf("vttablet doesn't take any positional arguments")
}
servenv.Init()
if *tabletPath == "" {
log.Fatalf("tabletPath required")
}
tabletAlias := tabletParamToTabletAlias(*tabletPath)
mycnf, err := mysqlctl.NewMycnfFromFlags(tabletAlias.Uid)
if err != nil {
log.Fatalf("mycnf read failed: %v", err)
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Warning(err)
}
dbcfgs.App.EnableRowcache = *enableRowcache
if *tableAclConfig != "" {
tableacl.Init(*tableAclConfig)
}
tabletserver.InitQueryService()
binlog.RegisterUpdateStreamService(mycnf)
// Depends on both query and updateStream.
agent, err = tabletmanager.NewActionAgent(tabletAlias, dbcfgs, mycnf, *servenv.Port, *servenv.SecurePort, *overridesFile)
if err != nil {
log.Fatal(err)
}
tabletmanager.HttpHandleSnapshots(mycnf, tabletAlias.Uid)
servenv.OnTerm(func() {
tabletserver.DisallowQueries()
binlog.DisableUpdateStreamService()
agent.Stop()
})
servenv.OnClose(func() {
// We will still use the topo server during lameduck period
// to update our state, so closing it in OnClose()
topo.CloseServers()
})
servenv.RunDefault()
}
示例9: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
// The implementation chain.
s := services.CreateServices()
for _, f := range vtgate.RegisterVTGates {
f(s)
}
servenv.RunDefault()
}
示例10: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
// The implementation chain.
c := newErrorClient(newSuccessClient(newTerminalClient()))
for _, f := range vtgate.RegisterVTGates {
f(c)
}
servenv.RunDefault()
}
示例11: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
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 {
schemafier, ok := ts.(topo.Schemafier)
if !ok {
log.Infof("Skipping v3 initialization: topo does not suppurt schemafier interface")
goto startServer
}
ctx := context.Background()
schemaJSON, err := schemafier.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")
// For the initial phase vtgate is exposing
// topoReader api. This will be subsumed by
// vtgate once vtgate's client functions become active.
topoReader = NewTopoReader(resilientSrvTopoServer)
servenv.Register("toporeader", topoReader)
vtgate.Init(resilientSrvTopoServer, schema, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, *maxInFlight)
servenv.RunDefault()
}
示例12: main
func main() {
flag.Parse()
servenv.Init()
defer servenv.Close()
ts = topo.GetServer()
defer topo.CloseServers()
// Init the vtctld core
vtctld.InitVtctld(ts)
// Start schema manager service.
initSchema()
// And run the server.
servenv.RunDefault()
}
示例13: main
func main() {
flag.Parse()
go servenv.RunDefault()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/throttlerz", http.StatusTemporaryRedirect)
})
log.Infof("start rate set to: %v", *rate)
replica := newReplica(*lagUpdateInterval, *replicaDegrationInterval, *replicaDegrationDuration)
master := &master{replica: replica}
client := newClient(master, replica)
client.run()
time.Sleep(*duration)
client.stop()
replica.stop()
}
示例14: main
func main() {
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
// For the initial phase vtgate is exposing
// topoReader api. This will be subsumed by
// vtgate once vtgate's client functions become active.
topoReader = NewTopoReader(resilientSrvTopoServer)
servenv.Register("toporeader", topoReader)
vtgate.Init(resilientSrvTopoServer, *cell, *retryDelay, *retryCount, *timeout, *maxInFlight)
servenv.RunDefault()
}
示例15: 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)
vtgate.Init(healthCheck, ts, resilientSrvTopoServer, schema, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, *maxInFlight, *testGateway)
servenv.RunDefault()
}