/
structs.go
179 lines (148 loc) · 4.46 KB
/
structs.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// 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 actionnode
import topodatapb "github.com/youtube/vitess/go/vt/proto/topodata"
/*
This file defines all the payload structures for the ActionNode objects.
The naming conventions are:
- a structure used for Args only is suffixed by 'Args'.
- a structure used for Reply only is suffixed by 'Reply'.
- a structure used for both Args and Reply is suffixed by 'Data'.
Note it's OK to rename the structures as the type name is not saved in json.
*/
// tablet action node structures
// SlaveWasRestartedArgs is the paylod for SlaveWasRestarted
type SlaveWasRestartedArgs struct {
Parent *topodatapb.TabletAlias
}
// shard action node structures
// SetShardServedTypesArgs is the payload for SetShardServedTypes
type SetShardServedTypesArgs struct {
Cells []string
ServedType topodatapb.TabletType
}
// MigrateServedTypesArgs is the payload for MigrateServedTypes
type MigrateServedTypesArgs struct {
ServedType topodatapb.TabletType
}
// keyspace action node structures
// ApplySchemaKeyspaceArgs is the payload for ApplySchemaKeyspace
type ApplySchemaKeyspaceArgs struct {
Change string
}
// MigrateServedFromArgs is the payload for MigrateServedFrom
type MigrateServedFromArgs struct {
ServedType topodatapb.TabletType
}
// methods to build the shard action nodes
// ReparentShardArgs is the payload for ReparentShard
type ReparentShardArgs struct {
Operation string
MasterElectAlias *topodatapb.TabletAlias
}
// ReparentShard returns an ActionNode
func ReparentShard(operation string, masterElectAlias *topodatapb.TabletAlias) *ActionNode {
return (&ActionNode{
Action: ShardActionReparent,
Args: &ReparentShardArgs{
Operation: operation,
MasterElectAlias: masterElectAlias,
},
}).SetGuid()
}
// ShardExternallyReparented returns an ActionNode
func ShardExternallyReparented(tabletAlias *topodatapb.TabletAlias) *ActionNode {
return (&ActionNode{
Action: ShardActionExternallyReparented,
Args: &tabletAlias,
}).SetGuid()
}
// RebuildShard returns an ActionNode
func RebuildShard() *ActionNode {
return (&ActionNode{
Action: ShardActionRebuild,
}).SetGuid()
}
// CheckShard returns an ActionNode
func CheckShard() *ActionNode {
return (&ActionNode{
Action: ShardActionCheck,
}).SetGuid()
}
// SetShardServedTypes returns an ActionNode
func SetShardServedTypes(cells []string, servedType topodatapb.TabletType) *ActionNode {
return (&ActionNode{
Action: ShardActionSetServedTypes,
Args: &SetShardServedTypesArgs{
Cells: cells,
ServedType: servedType,
},
}).SetGuid()
}
// MigrateServedTypes returns an ActionNode
func MigrateServedTypes(servedType topodatapb.TabletType) *ActionNode {
return (&ActionNode{
Action: ShardActionMigrateServedTypes,
Args: &MigrateServedTypesArgs{
ServedType: servedType,
},
}).SetGuid()
}
// UpdateShard returns an ActionNode
func UpdateShard() *ActionNode {
return (&ActionNode{
Action: ShardActionUpdateShard,
}).SetGuid()
}
// methods to build the keyspace action nodes
// RebuildKeyspace returns an ActionNode
func RebuildKeyspace() *ActionNode {
return (&ActionNode{
Action: KeyspaceActionRebuild,
}).SetGuid()
}
// SetKeyspaceShardingInfo returns an ActionNode
func SetKeyspaceShardingInfo() *ActionNode {
return (&ActionNode{
Action: KeyspaceActionSetShardingInfo,
}).SetGuid()
}
// SetKeyspaceServedFrom returns an ActionNode
func SetKeyspaceServedFrom() *ActionNode {
return (&ActionNode{
Action: KeyspaceActionSetServedFrom,
}).SetGuid()
}
// ApplySchemaKeyspace returns an ActionNode
func ApplySchemaKeyspace(change string) *ActionNode {
return (&ActionNode{
Action: KeyspaceActionApplySchema,
Args: &ApplySchemaKeyspaceArgs{
Change: change,
},
}).SetGuid()
}
// MigrateServedFrom returns an ActionNode
func MigrateServedFrom(servedType topodatapb.TabletType) *ActionNode {
return (&ActionNode{
Action: KeyspaceActionMigrateServedFrom,
Args: &MigrateServedFromArgs{
ServedType: servedType,
},
}).SetGuid()
}
// KeyspaceCreateShard returns an ActionNode to use to lock a keyspace
// for shard creation
func KeyspaceCreateShard() *ActionNode {
return (&ActionNode{
Action: KeyspaceActionCreateShard,
}).SetGuid()
}
//methods to build the serving shard action nodes
// RebuildSrvShard returns an ActionNode
func RebuildSrvShard() *ActionNode {
return (&ActionNode{
Action: SrvShardActionRebuild,
}).SetGuid()
}