• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang servenv.AddStatusPart函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang servenv.Close函数代码示例发布时间:2022-05-28
下一篇:
Golang schemamanager.Run函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap