forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc_client_api.go
112 lines (82 loc) · 4.48 KB
/
rpc_client_api.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright 2013, 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 initiator
import (
"time"
log "github.com/golang/glog"
mproto "github.com/youtube/vitess/go/mysql/proto"
blproto "github.com/youtube/vitess/go/vt/binlog/proto"
myproto "github.com/youtube/vitess/go/vt/mysqlctl/proto"
"github.com/youtube/vitess/go/vt/tabletmanager/actionnode"
"github.com/youtube/vitess/go/vt/topo"
)
// TabletManagerConn defines the interface used to talk to a remote tablet
type TabletManagerConn interface {
//
// Various read-only methods
//
// Ping will try to ping the remote tablet
Ping(tablet *topo.TabletInfo, waitTime time.Duration) error
// GetSchema asks the remote tablet for its database schema
GetSchema(tablet *topo.TabletInfo, tables, excludeTables []string, includeViews bool, waitTime time.Duration) (*myproto.SchemaDefinition, error)
// GetPermissions asks the remote tablet for its permissions list
GetPermissions(tablet *topo.TabletInfo, waitTime time.Duration) (*myproto.Permissions, error)
//
// Various read-write methods
//
// ChangeType asks the remote tablet to change its type
ChangeType(tablet *topo.TabletInfo, dbType topo.TabletType, waitTime time.Duration) error
// SetBlacklistedTables asks the remote tablet to change its
// blacklisted tables list
SetBlacklistedTables(tablet *topo.TabletInfo, tables []string, waitTime time.Duration) error
// ReloadSchema asks the remote tablet to reload its schema
ReloadSchema(tablet *topo.TabletInfo, waitTime time.Duration) error
// ExecuteFetch executes a query remotely using the DBA pool
ExecuteFetch(tablet *topo.TabletInfo, query string, maxRows int, wantFields, disableBinlogs bool, waitTime time.Duration) (*mproto.QueryResult, error)
//
// Replication related methods
//
// SlavePosition returns the tablet's mysql slave position
SlavePosition(tablet *topo.TabletInfo, waitTime time.Duration) (*myproto.ReplicationPosition, error)
// WaitSlavePosition asks the tablet to wait until it reaches that
// position in mysql replication
WaitSlavePosition(tablet *topo.TabletInfo, replicationPosition *myproto.ReplicationPosition, waitTime time.Duration) (*myproto.ReplicationPosition, error)
// MasterPosition returns the tablet's master position
MasterPosition(tablet *topo.TabletInfo, waitTime time.Duration) (*myproto.ReplicationPosition, error)
// StopSlave stops the mysql replication
StopSlave(tablet *topo.TabletInfo, waitTime time.Duration) error
// StopSlaveMinimum stops the mysql replication after it reaches
// the provided minimum point
StopSlaveMinimum(tablet *topo.TabletInfo, groupId int64, waitTime time.Duration) (*myproto.ReplicationPosition, error)
// StartSlave starts the mysql replication
StartSlave(tablet *topo.TabletInfo, waitTime time.Duration) error
// GetSlaves returns the addresses of the slaves
GetSlaves(tablet *topo.TabletInfo, waitTime time.Duration) ([]string, error)
// WaitBlpPosition asks the tablet to wait until it reaches that
// position in replication
WaitBlpPosition(tablet *topo.TabletInfo, blpPosition blproto.BlpPosition, waitTime time.Duration) error
// StopBlp asks the tablet to stop all its binlog players,
// and returns the current position for all of them
StopBlp(tablet *topo.TabletInfo, waitTime time.Duration) (*blproto.BlpPositionList, error)
// StartBlp asks the tablet to restart its binlog players
StartBlp(tablet *topo.TabletInfo, waitTime time.Duration) error
// RunBlpUntil asks the tablet to restart its binlog players until
// it reaches the given positions, if not there yet.
RunBlpUntil(tablet *topo.TabletInfo, positions *blproto.BlpPositionList, waitTime time.Duration) (*myproto.ReplicationPosition, error)
//
// Reparenting related functions
//
// SlaveWasPromoted tells the remote tablet it is now the master
SlaveWasPromoted(tablet *topo.TabletInfo, waitTime time.Duration) error
// SlaveWasRestarted tells the remote tablet its master has changed
SlaveWasRestarted(tablet *topo.TabletInfo, args *actionnode.SlaveWasRestartedArgs, waitTime time.Duration) error
}
type TabletManagerConnFactory func(topo.Server) TabletManagerConn
var tabletManagerConnFactories = make(map[string]TabletManagerConnFactory)
func RegisterTabletManagerConnFactory(name string, factory TabletManagerConnFactory) {
if _, ok := tabletManagerConnFactories[name]; ok {
log.Fatalf("RegisterTabletManagerConn %s already exists", name)
}
tabletManagerConnFactories[name] = factory
}