forked from redis/rueidis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
334 lines (287 loc) · 10.6 KB
/
client.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
package mock
import (
"context"
"reflect"
"time"
"github.com/redis/rueidis"
"github.com/redis/rueidis/internal/cmds"
"go.uber.org/mock/gomock"
)
var _ rueidis.Client = (*Client)(nil)
var _ rueidis.DedicatedClient = (*DedicatedClient)(nil)
// ClientOption is optional function parameter for NewClient
type ClientOption func(c any)
// WithSlotCheck enables the command builder of Client to check if the command built across multiple slots and then panic
func WithSlotCheck() ClientOption {
return func(c any) {
if cc, ok := c.(*Client); ok {
cc.slot = cmds.InitSlot
}
if cc, ok := c.(*DedicatedClient); ok {
cc.slot = cmds.InitSlot
}
}
}
// Client is a mock of Client interface.
type Client struct {
ctrl *gomock.Controller
recorder *ClientMockRecorder
slot uint16
}
// ClientMockRecorder is the mock recorder for Client.
type ClientMockRecorder struct {
mock *Client
}
// NewClient creates a new mock instance.
func NewClient(ctrl *gomock.Controller, options ...ClientOption) *Client {
mock := &Client{ctrl: ctrl, slot: cmds.NoSlot}
mock.recorder = &ClientMockRecorder{mock}
for _, opt := range options {
opt(mock)
}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *Client) EXPECT() *ClientMockRecorder {
return m.recorder
}
// B mocks base method.
func (m *Client) B() rueidis.Builder {
return cmds.NewBuilder(m.slot)
}
// Close mocks base method.
func (m *Client) Close() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Close")
}
// Close indicates an expected call of Close.
func (mr *ClientMockRecorder) Close() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*Client)(nil).Close))
}
// Dedicate mocks base method.
func (m *Client) Dedicate() (rueidis.DedicatedClient, func()) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Dedicate")
ret0, _ := ret[0].(rueidis.DedicatedClient)
ret1, _ := ret[1].(func())
return ret0, ret1
}
// Dedicate indicates an expected call of Dedicate.
func (mr *ClientMockRecorder) Dedicate() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dedicate", reflect.TypeOf((*Client)(nil).Dedicate))
}
// Dedicated mocks base method.
func (m *Client) Dedicated(arg0 func(rueidis.DedicatedClient) error) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Dedicated", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Dedicated indicates an expected call of Dedicated.
func (mr *ClientMockRecorder) Dedicated(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dedicated", reflect.TypeOf((*Client)(nil).Dedicated), arg0)
}
// Do mocks base method.
func (m *Client) Do(arg0 context.Context, arg1 rueidis.Completed) rueidis.RedisResult {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Do", arg0, arg1)
ret0, _ := ret[0].(rueidis.RedisResult)
return ret0
}
// Do indicates an expected call of Do.
func (mr *ClientMockRecorder) Do(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*Client)(nil).Do), arg0, arg1)
}
// DoStream mocks base method.
func (m *Client) DoStream(arg0 context.Context, arg1 rueidis.Completed) rueidis.RedisResultStream {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DoStream", arg0, arg1)
ret0, _ := ret[0].(rueidis.RedisResultStream)
return ret0
}
// DoStream indicates an expected call of DoStream.
func (mr *ClientMockRecorder) DoStream(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoStream", reflect.TypeOf((*Client)(nil).DoStream), arg0, arg1)
}
// DoCache mocks base method.
func (m *Client) DoCache(arg0 context.Context, arg1 rueidis.Cacheable, arg2 time.Duration) rueidis.RedisResult {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DoCache", arg0, arg1, arg2)
ret0, _ := ret[0].(rueidis.RedisResult)
return ret0
}
// DoCache indicates an expected call of DoCache.
func (mr *ClientMockRecorder) DoCache(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoCache", reflect.TypeOf((*Client)(nil).DoCache), arg0, arg1, arg2)
}
// DoMulti mocks base method.
func (m *Client) DoMulti(arg0 context.Context, arg1 ...rueidis.Completed) []rueidis.RedisResult {
m.ctrl.T.Helper()
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "DoMulti", varargs...)
ret0, _ := ret[0].([]rueidis.RedisResult)
return ret0
}
// DoMulti indicates an expected call of DoMulti.
func (mr *ClientMockRecorder) DoMulti(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoMulti", reflect.TypeOf((*Client)(nil).DoMulti), varargs...)
}
// DoMultiStream mocks base method.
func (m *Client) DoMultiStream(arg0 context.Context, arg1 ...rueidis.Completed) rueidis.MultiRedisResultStream {
m.ctrl.T.Helper()
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "DoMultiStream", varargs...)
ret0, _ := ret[0].(rueidis.MultiRedisResultStream)
return ret0
}
// DoMultiStream indicates an expected call of DoMultiStream.
func (mr *ClientMockRecorder) DoMultiStream(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoMultiStream", reflect.TypeOf((*Client)(nil).DoMultiStream), varargs...)
}
// DoMultiCache mocks base method.
func (m *Client) DoMultiCache(arg0 context.Context, arg1 ...rueidis.CacheableTTL) []rueidis.RedisResult {
m.ctrl.T.Helper()
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "DoMultiCache", varargs...)
ret0, _ := ret[0].([]rueidis.RedisResult)
return ret0
}
// DoMultiCache indicates an expected call of DoMultiCache.
func (mr *ClientMockRecorder) DoMultiCache(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoMultiCache", reflect.TypeOf((*Client)(nil).DoMultiCache), varargs...)
}
// Nodes mocks base method.
func (m *Client) Nodes() map[string]rueidis.Client {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Nodes")
ret0, _ := ret[0].(map[string]rueidis.Client)
return ret0
}
// Nodes indicates an expected call of Nodes.
func (mr *ClientMockRecorder) Nodes() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nodes", reflect.TypeOf((*Client)(nil).Nodes))
}
// Receive mocks base method.
func (m *Client) Receive(arg0 context.Context, arg1 rueidis.Completed, arg2 func(rueidis.PubSubMessage)) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Receive", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
}
// Receive indicates an expected call of Receive.
func (mr *ClientMockRecorder) Receive(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Receive", reflect.TypeOf((*Client)(nil).Receive), arg0, arg1, arg2)
}
// DedicatedClient is a mock of DedicatedClient interface.
type DedicatedClient struct {
ctrl *gomock.Controller
recorder *DedicatedClientMockRecorder
slot uint16
}
// DedicatedClientMockRecorder is the mock recorder for DedicatedClient.
type DedicatedClientMockRecorder struct {
mock *DedicatedClient
}
// NewDedicatedClient creates a new mock instance.
func NewDedicatedClient(ctrl *gomock.Controller, options ...ClientOption) *DedicatedClient {
mock := &DedicatedClient{ctrl: ctrl, slot: cmds.NoSlot}
mock.recorder = &DedicatedClientMockRecorder{mock}
for _, opt := range options {
opt(mock)
}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *DedicatedClient) EXPECT() *DedicatedClientMockRecorder {
return m.recorder
}
// B mocks base method.
func (m *DedicatedClient) B() rueidis.Builder {
return cmds.NewBuilder(m.slot)
}
// Close mocks base method.
func (m *DedicatedClient) Close() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Close")
}
// Close indicates an expected call of Close.
func (mr *DedicatedClientMockRecorder) Close() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*DedicatedClient)(nil).Close))
}
// Do mocks base method.
func (m *DedicatedClient) Do(arg0 context.Context, arg1 rueidis.Completed) rueidis.RedisResult {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Do", arg0, arg1)
ret0, _ := ret[0].(rueidis.RedisResult)
return ret0
}
// Do indicates an expected call of Do.
func (mr *DedicatedClientMockRecorder) Do(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*DedicatedClient)(nil).Do), arg0, arg1)
}
// DoMulti mocks base method.
func (m *DedicatedClient) DoMulti(arg0 context.Context, arg1 ...rueidis.Completed) []rueidis.RedisResult {
m.ctrl.T.Helper()
varargs := []any{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "DoMulti", varargs...)
ret0, _ := ret[0].([]rueidis.RedisResult)
return ret0
}
// DoMulti indicates an expected call of DoMulti.
func (mr *DedicatedClientMockRecorder) DoMulti(arg0 any, arg1 ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoMulti", reflect.TypeOf((*DedicatedClient)(nil).DoMulti), varargs...)
}
// Receive mocks base method.
func (m *DedicatedClient) Receive(arg0 context.Context, arg1 rueidis.Completed, arg2 func(rueidis.PubSubMessage)) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Receive", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
}
// Receive indicates an expected call of Receive.
func (mr *DedicatedClientMockRecorder) Receive(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Receive", reflect.TypeOf((*DedicatedClient)(nil).Receive), arg0, arg1, arg2)
}
// SetPubSubHooks mocks base method.
func (m *DedicatedClient) SetPubSubHooks(arg0 rueidis.PubSubHooks) <-chan error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetPubSubHooks", arg0)
ret0, _ := ret[0].(<-chan error)
return ret0
}
// SetPubSubHooks indicates an expected call of SetPubSubHooks.
func (mr *DedicatedClientMockRecorder) SetPubSubHooks(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPubSubHooks", reflect.TypeOf((*DedicatedClient)(nil).SetPubSubHooks), arg0)
}