當前位置: 首頁>>代碼示例>>Golang>>正文


Golang servenv.AddStatusPart函數代碼示例

本文整理匯總了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()
		}
	})
}
開發者ID:nangong92t,項目名稱:go_src,代碼行數:25,代碼來源:status.go

示例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()
	}
}
開發者ID:jmptrader,項目名稱:vitess,代碼行數:26,代碼來源:status.go

示例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()
	}
}
開發者ID:richarwu,項目名稱:vitess,代碼行數:27,代碼來源:status.go

示例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
		})
	})
}
開發者ID:chinna1986,項目名稱:vitess,代碼行數:10,代碼來源:status.go

示例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()
	}
}
開發者ID:littleyang,項目名稱:vitess,代碼行數:14,代碼來源:status.go

示例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()
		}
	})
}
開發者ID:hadmagic,項目名稱:vitess,代碼行數:16,代碼來源:status.go

示例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)
		}
	})
}
開發者ID:chinna1986,項目名稱:vitess,代碼行數:59,代碼來源:status.go

示例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()
	})
}
開發者ID:qman1989,項目名稱:vitess,代碼行數:13,代碼來源:status.go

示例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
	})
}
開發者ID:chinna1986,項目名稱:vitess,代碼行數:14,代碼來源:status.go

示例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
	})
}
開發者ID:richarwu,項目名稱:vitess,代碼行數:14,代碼來源:status.go

示例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
	})
}
開發者ID:Rastusik,項目名稱:vitess,代碼行數:14,代碼來源:status.go

示例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)

	})
}
開發者ID:littleyang,項目名稱:vitess,代碼行數:80,代碼來源:status.go


注:本文中的github.com/youtube/vitess/go/vt/servenv.AddStatusPart函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。