本文整理汇总了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
}
示例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()
}
示例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()
}
示例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)
}