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


Golang hook.Hook類代碼示例

本文整理匯總了Golang中github.com/youtube/vitess/go/vt/hook.Hook的典型用法代碼示例。如果您正苦於以下問題:Golang Hook類的具體用法?Golang Hook怎麽用?Golang Hook使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Hook類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ExecuteHook

// ExecuteHook executes the provided hook locally, and returns the result.
func (agent *ActionAgent) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult {
	if err := agent.lock(ctx); err != nil {
		// client gave up
		return &hook.HookResult{}
	}
	defer agent.unlock()

	// Execute the hooks
	topotools.ConfigureTabletHook(hk, agent.TabletAlias)
	hr := hk.Execute()

	// We never know what the hook did, so let's refresh our state.
	if err := agent.refreshTablet(ctx, "ExecuteHook"); err != nil {
		log.Errorf("refreshTablet after ExecuteHook failed: %v", err)
	}

	return hr
}
開發者ID:erzel,項目名稱:vitess,代碼行數:19,代碼來源:rpc_actions.go

示例2: configureTabletHook

// add TABLET_ALIAS to environment
func configureTabletHook(hk *hook.Hook, tabletAlias topo.TabletAlias) {
	if hk.ExtraEnv == nil {
		hk.ExtraEnv = make(map[string]string, 1)
	}
	hk.ExtraEnv["TABLET_ALIAS"] = tabletAlias.String()
}
開發者ID:rrudduck,項目名稱:golang-stuff,代碼行數:7,代碼來源:actor.go

示例3: ExecuteHook

// ExecuteHook executes the provided hook locally, and returns the result.
// Should be called under RPCWrapLockAction.
func (agent *ActionAgent) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult {
	topotools.ConfigureTabletHook(hk, agent.TabletAlias)
	return hk.Execute()
}
開發者ID:littleyang,項目名稱:vitess,代碼行數:6,代碼來源:agent_rpc_actions.go

示例4: ConfigureTabletHook

// ConfigureTabletHook configures the right parameters for a hook
// running locally on a tablet.
func ConfigureTabletHook(hk *hook.Hook, tabletAlias *topodatapb.TabletAlias) {
	if hk.ExtraEnv == nil {
		hk.ExtraEnv = make(map[string]string, 1)
	}
	hk.ExtraEnv["TABLET_ALIAS"] = topoproto.TabletAliasString(tabletAlias)
}
開發者ID:tjyang,項目名稱:vitess,代碼行數:8,代碼來源:tablet.go


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