本文整理汇总了Golang中github.com/youtube/vitess/go/vt/servenv.AddStatusPart函数的典型用法代码示例。如果您正苦于以下问题:Golang AddStatusPart函数的具体用法?Golang AddStatusPart怎么用?Golang AddStatusPart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddStatusPart函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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()
}
})
}
示例2: addStatusParts
func addStatusParts(qsc tabletserver.Controller) {
servenv.AddStatusPart("Tablet", tabletTemplate, func() interface{} {
return map[string]interface{}{
"Tablet": topo.NewTabletInfo(agent.Tablet(), -1),
"BlacklistedTables": agent.BlacklistedTables(),
"DisallowQueryService": agent.DisallowQueryService(),
"DisableUpdateStream": !agent.EnableUpdateStream(),
}
})
servenv.AddStatusFuncs(template.FuncMap{
"github_com_youtube_vitess_health_html_name": healthHTMLName,
})
servenv.AddStatusPart("Health", healthTemplate, func() interface{} {
return &healthStatus{
Records: agent.History.Records(),
Config: tabletmanager.ConfigHTML(),
}
})
qsc.AddStatusPart()
servenv.AddStatusPart("Binlog Player", binlogTemplate, func() interface{} {
return agent.BinlogPlayerMap.Status()
})
if onStatusRegistered != nil {
onStatusRegistered()
}
}
示例3: addStatusParts
func addStatusParts(qsc tabletserver.QueryServiceControl) {
servenv.AddStatusPart("Tablet", tabletTemplate, func() interface{} {
return map[string]interface{}{
"Tablet": agent.Tablet(),
"BlacklistedTables": agent.BlacklistedTables(),
"DisableQueryService": agent.DisableQueryService(),
}
})
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(),
Config: tabletmanager.ConfigHTML(),
}
})
}
qsc.AddStatusPart()
servenv.AddStatusPart("Binlog Player", binlogTemplate, func() interface{} {
return agent.BinlogPlayerMap.Status()
})
if onStatusRegistered != nil {
onStatusRegistered()
}
}
示例4: init
func init() {
servenv.OnRun(func() {
servenv.AddStatusPart("Topology Cache", topoTemplate, func() interface{} {
return resilientSrvTopoServer.CacheStatus()
})
servenv.AddStatusPart("Stats", statsTemplate, func() interface{} {
return nil
})
})
}
示例5: addStatusParts
func addStatusParts(vtgate *vtgate.VTGate) {
servenv.AddStatusPart("Topology Cache", topoTemplate, func() interface{} {
return resilientSrvTopoServer.CacheStatus()
})
servenv.AddStatusPart("Gateway Status", gatewayStatusTemplate, func() interface{} {
return vtgate.GetGatewayCacheStatus()
})
servenv.AddStatusPart("Health Check Cache (NOT FOR QUERY ROUTING)", healthCheckTemplate, func() interface{} {
return healthCheck.CacheStatus()
})
if onStatusRegistered != nil {
onStatusRegistered()
}
}
示例6: init
func init() {
servenv.OnRun(func() {
servenv.AddStatusPart("Topology Cache", topoTemplate, func() interface{} {
return resilientSrvTopoServer.CacheStatus()
})
servenv.AddStatusPart("Health Check Cache (NOT FOR QUERY ROUTING)", healthCheckTemplate, func() interface{} {
return healthCheck.CacheStatus()
})
servenv.AddStatusPart("Stats", statsTemplate, func() interface{} {
return nil
})
if onStatusRegistered != nil {
onStatusRegistered()
}
})
}
示例7: initStatusHandling
func initStatusHandling() {
// code to serve /status
workerTemplate := loadTemplate("worker", workerStatusHTML)
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
currentWorkerMutex.Lock()
wrk := currentWorker
logger := currentMemoryLogger
done := currentDone
currentWorkerMutex.Unlock()
data := make(map[string]interface{})
if wrk != nil {
data["Status"] = wrk.StatusAsHTML()
select {
case <-done:
data["Done"] = true
default:
}
if logger != nil {
data["Logs"] = template.HTML(strings.Replace(logger.String(), "\n", "</br>\n", -1))
} else {
data["Logs"] = template.HTML("See console for logs</br>\n")
}
}
executeTemplate(w, workerTemplate, data)
})
// add the section in statusz that does auto-refresh of status div
servenv.AddStatusPart("Worker Status", workerStatusPartHTML, func() interface{} {
return nil
})
// reset handler
http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) {
currentWorkerMutex.Lock()
wrk := currentWorker
done := currentDone
currentWorkerMutex.Unlock()
// no worker, we go to the menu
if wrk == nil {
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
return
}
// check the worker is really done
select {
case <-done:
currentWorkerMutex.Lock()
currentWorker = nil
currentMemoryLogger = nil
currentDone = nil
currentWorkerMutex.Unlock()
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
default:
httpError(w, "worker still executing", nil)
}
})
}
示例8: init
func init() {
servenv.OnRun(func() {
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()
})
}
示例9: AddStatusPart
// AddStatusPart registers the status part for the status page.
func AddStatusPart() {
servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
status := queryserviceStatus{
State: SqlQueryRpcService.GetState(),
}
rates := QPSRates.Get()
if qps, ok := rates["All"]; ok && len(qps) > 0 {
status.CurrentQPS = qps[0]
}
return status
})
}
示例10: AddStatusPart
// AddStatusPart registers the status part for the status page.
func (rqsc *realQueryServiceControl) AddStatusPart() {
servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
status := queryserviceStatus{
State: rqsc.tabletServerRPCService.GetState(),
}
rates := rqsc.tabletServerRPCService.qe.queryServiceStats.QPSRates.Get()
if qps, ok := rates["All"]; ok && len(qps) > 0 {
status.CurrentQPS = qps[0]
}
return status
})
}
示例11: AddStatusPart
// AddStatusPart registers the status part for the status page.
func (tsv *TabletServer) AddStatusPart() {
servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
status := queryserviceStatus{
State: tsv.GetState(),
History: tsv.history.Records(),
}
rates := tsv.qe.queryServiceStats.QPSRates.Get()
if qps, ok := rates["All"]; ok && len(qps) > 0 {
status.CurrentQPS = qps[0]
}
return status
})
}
示例12: InitStatusHandling
// InitStatusHandling installs webserver handlers for global actions like /status, /reset and /cancel.
func (wi *Instance) InitStatusHandling() {
// code to serve /status
workerTemplate := mustParseTemplate("worker", workerStatusHTML)
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
wi.currentWorkerMutex.Lock()
wrk := wi.currentWorker
logger := wi.currentMemoryLogger
ctx := wi.currentContext
err := wi.lastRunError
wi.currentWorkerMutex.Unlock()
data := make(map[string]interface{})
if wrk != nil {
status := template.HTML("Current worker:<br>\n") + wrk.StatusAsHTML()
if ctx == nil {
data["Done"] = true
if err != nil {
status += template.HTML(fmt.Sprintf("<br>\nEnded with an error: %v<br>\n", err))
}
}
data["Status"] = status
if logger != nil {
data["Logs"] = template.HTML(strings.Replace(logger.String(), "\n", "</br>\n", -1))
} else {
data["Logs"] = template.HTML("See console for logs</br>\n")
}
}
executeTemplate(w, workerTemplate, data)
})
// add the section in status that does auto-refresh of status div
servenv.AddStatusPart("Worker Status", workerStatusPartHTML, func() interface{} {
return nil
})
// reset handler
http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
if err := wi.Reset(); err != nil {
httpError(w, err.Error(), nil)
} else {
// No worker currently running, we go to the menu.
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
}
})
// cancel handler
http.HandleFunc("/cancel", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
wi.currentWorkerMutex.Lock()
// no worker, or not running, we go to the menu
if wi.currentWorker == nil || wi.currentCancelFunc == nil {
wi.currentWorkerMutex.Unlock()
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
return
}
// otherwise, cancel the running worker and go back to the status page
cancel := wi.currentCancelFunc
wi.currentWorkerMutex.Unlock()
cancel()
http.Redirect(w, r, servenv.StatusURLPath(), http.StatusTemporaryRedirect)
})
}