forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.go
32 lines (26 loc) · 1 KB
/
hook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package wrangler
import (
"fmt"
"strings"
hk "github.com/youtube/vitess/go/vt/hook"
"golang.org/x/net/context"
topodatapb "github.com/youtube/vitess/go/vt/proto/topodata"
)
// ExecuteHook will run the hook on the tablet
func (wr *Wrangler) ExecuteHook(ctx context.Context, tabletAlias *topodatapb.TabletAlias, hook *hk.Hook) (hookResult *hk.HookResult, err error) {
if strings.Contains(hook.Name, "/") {
return nil, fmt.Errorf("hook name cannot have a '/' in it")
}
ti, err := wr.ts.GetTablet(ctx, tabletAlias)
if err != nil {
return nil, err
}
return wr.ExecuteTabletHook(ctx, ti.Tablet, hook)
}
// ExecuteTabletHook will run the hook on the provided tablet.
func (wr *Wrangler) ExecuteTabletHook(ctx context.Context, tablet *topodatapb.Tablet, hook *hk.Hook) (hookResult *hk.HookResult, err error) {
return wr.tmc.ExecuteHook(ctx, tablet, hook)
}