forked from vitessio/vitess
/
faketopo.go
220 lines (174 loc) · 8.07 KB
/
faketopo.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// Package faketopo contains utitlities for tests that have to interact with a
// Vitess topology.
package faketopo
import (
"errors"
"github.com/youtube/vitess/go/vt/topo"
"golang.org/x/net/context"
topodatapb "github.com/youtube/vitess/go/vt/proto/topodata"
vschemapb "github.com/youtube/vitess/go/vt/proto/vschema"
)
var errNotImplemented = errors.New("Not implemented")
// FakeTopo is a topo.Server implementation that always returns errNotImplemented errors.
type FakeTopo struct{}
// Close is part of the topo.Server interface.
func (ft FakeTopo) Close() {}
// ListDir is part of the topo.Backend interface.
func (ft FakeTopo) ListDir(ctx context.Context, cell, dirPath string) ([]string, error) {
return nil, errNotImplemented
}
// Create is part of the topo.Backend interface.
func (ft FakeTopo) Create(ctx context.Context, cell, filePath string, contents []byte) (topo.Version, error) {
return nil, errNotImplemented
}
// Update is part of the topo.Backend interface.
func (ft FakeTopo) Update(ctx context.Context, cell, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
return nil, errNotImplemented
}
// Get is part of the topo.Backend interface.
func (ft FakeTopo) Get(ctx context.Context, cell, filePath string) ([]byte, topo.Version, error) {
return nil, nil, errNotImplemented
}
// Delete is part of the topo.Backend interface.
func (ft FakeTopo) Delete(ctx context.Context, cell, filePath string, version topo.Version) error {
return errNotImplemented
}
// Watch is part of the topo.Backend interface.
func (ft FakeTopo) Watch(ctx context.Context, cell string, path string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc) {
return &topo.WatchData{
Err: errNotImplemented,
}, nil, nil
}
// GetKnownCells is part of the topo.Server interface.
func (ft FakeTopo) GetKnownCells(ctx context.Context) ([]string, error) {
return nil, errNotImplemented
}
// CreateKeyspace is part of the topo.Server interface.
func (ft FakeTopo) CreateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace) error {
return errNotImplemented
}
// UpdateKeyspace is part of the topo.Server interface.
func (ft FakeTopo) UpdateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace, existingVersion int64) (int64, error) {
return 0, errNotImplemented
}
// DeleteKeyspace is part of the topo.Server interface.
func (ft FakeTopo) DeleteKeyspace(ctx context.Context, keyspace string) error {
return errNotImplemented
}
// GetKeyspace is part of the topo.Server interface.
func (ft FakeTopo) GetKeyspace(ctx context.Context, keyspace string) (*topodatapb.Keyspace, int64, error) {
return nil, 0, errNotImplemented
}
// GetKeyspaces is part of the topo.Server interface.
func (ft FakeTopo) GetKeyspaces(ctx context.Context) ([]string, error) {
return nil, errNotImplemented
}
// CreateShard is part of the topo.Server interface.
func (ft FakeTopo) CreateShard(ctx context.Context, keyspace, shard string, value *topodatapb.Shard) error {
return errNotImplemented
}
// UpdateShard is part of the topo.Server interface.
func (ft FakeTopo) UpdateShard(ctx context.Context, keyspace, shard string, value *topodatapb.Shard, existingVersion int64) (int64, error) {
return 0, errNotImplemented
}
// GetShard is part of the topo.Server interface.
func (ft FakeTopo) GetShard(ctx context.Context, keyspace, shard string) (*topodatapb.Shard, int64, error) {
return nil, 0, errNotImplemented
}
// GetShardNames is part of the topo.Server interface.
func (ft FakeTopo) GetShardNames(ctx context.Context, keyspace string) ([]string, error) {
return nil, errNotImplemented
}
// DeleteShard is part of the topo.Server interface.
func (ft FakeTopo) DeleteShard(ctx context.Context, keyspace, shard string) error {
return errNotImplemented
}
// CreateTablet is part of the topo.Server interface.
func (ft FakeTopo) CreateTablet(ctx context.Context, tablet *topodatapb.Tablet) error {
return errNotImplemented
}
// UpdateTablet is part of the topo.Server interface.
func (ft FakeTopo) UpdateTablet(ctx context.Context, tablet *topodatapb.Tablet, existingVersion int64) (newVersion int64, err error) {
return 0, errNotImplemented
}
// DeleteTablet is part of the topo.Server interface.
func (ft FakeTopo) DeleteTablet(ctx context.Context, alias *topodatapb.TabletAlias) error {
return errNotImplemented
}
// GetTablet is part of the topo.Server interface.
func (ft FakeTopo) GetTablet(ctx context.Context, alias *topodatapb.TabletAlias) (*topodatapb.Tablet, int64, error) {
return nil, 0, errNotImplemented
}
// GetTabletsByCell is part of the topo.Server interface.
func (ft FakeTopo) GetTabletsByCell(ctx context.Context, cell string) ([]*topodatapb.TabletAlias, error) {
return nil, errNotImplemented
}
// UpdateShardReplicationFields is part of the topo.Server interface.
func (ft FakeTopo) UpdateShardReplicationFields(ctx context.Context, cell, keyspace, shard string, update func(*topodatapb.ShardReplication) error) error {
return errNotImplemented
}
// GetShardReplication is part of the topo.Server interface.
func (ft FakeTopo) GetShardReplication(ctx context.Context, cell, keyspace, shard string) (*topo.ShardReplicationInfo, error) {
return nil, errNotImplemented
}
// DeleteShardReplication is part of the topo.Server interface.
func (ft FakeTopo) DeleteShardReplication(ctx context.Context, cell, keyspace, shard string) error {
return errNotImplemented
}
// DeleteKeyspaceReplication is part of the topo.Server interface.
func (ft FakeTopo) DeleteKeyspaceReplication(ctx context.Context, cell, keyspace string) error {
return errNotImplemented
}
// GetSrvKeyspaceNames is part of the topo.Server interface.
func (ft FakeTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) {
return nil, errNotImplemented
}
// UpdateSrvKeyspace is part of the topo.Server interface.
func (ft FakeTopo) UpdateSrvKeyspace(ctx context.Context, cell, keyspace string, srvKeyspace *topodatapb.SrvKeyspace) error {
return errNotImplemented
}
// DeleteSrvKeyspace is part of the topo.Server interface.
func (ft FakeTopo) DeleteSrvKeyspace(ctx context.Context, cell, keyspace string) error {
return errNotImplemented
}
// GetSrvKeyspace is part of the topo.Server interface.
func (ft FakeTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
return nil, errNotImplemented
}
// UpdateSrvVSchema is part of the topo.Server interface.
func (ft FakeTopo) UpdateSrvVSchema(ctx context.Context, cell string, srvVSchema *vschemapb.SrvVSchema) error {
return errNotImplemented
}
// GetSrvVSchema is part of the topo.Server interface.
func (ft FakeTopo) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error) {
return nil, errNotImplemented
}
// LockKeyspaceForAction is part of the topo.Server interface.
func (ft FakeTopo) LockKeyspaceForAction(ctx context.Context, keyspace, contents string) (string, error) {
return "", errNotImplemented
}
// UnlockKeyspaceForAction is part of the topo.Server interface.
func (ft FakeTopo) UnlockKeyspaceForAction(ctx context.Context, keyspace, lockPath, results string) error {
return errNotImplemented
}
// LockShardForAction is part of the topo.Server interface.
func (ft FakeTopo) LockShardForAction(ctx context.Context, keyspace, shard, contents string) (string, error) {
return "", errNotImplemented
}
// UnlockShardForAction is part of the topo.Server interface.
func (ft FakeTopo) UnlockShardForAction(ctx context.Context, keyspace, shard, lockPath, results string) error {
return errNotImplemented
}
// SaveVSchema is part of the topo.Server interface.
func (ft FakeTopo) SaveVSchema(context.Context, string, *vschemapb.Keyspace) error {
return errNotImplemented
}
// GetVSchema is part of the topo.Server interface.
func (ft FakeTopo) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.Keyspace, error) {
return nil, errNotImplemented
}
// NewMasterParticipation is part of the topo.Server interface.
func (ft FakeTopo) NewMasterParticipation(name, id string) (topo.MasterParticipation, error) {
return nil, errNotImplemented
}
var _ topo.Impl = (*FakeTopo)(nil) // compile-time interface check