-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Broker.go
218 lines (174 loc) · 4.86 KB
/
Broker.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
// Code generated by mockery v2.20.0. DO NOT EDIT.
package mocks
import (
broker "github.com/anycable/anycable-go/broker"
common "github.com/anycable/anycable-go/common"
context "context"
mock "github.com/stretchr/testify/mock"
)
// Broker is an autogenerated mock type for the Broker type
type Broker struct {
mock.Mock
}
// Announce provides a mock function with given fields:
func (_m *Broker) Announce() string {
ret := _m.Called()
var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}
return r0
}
// CommitSession provides a mock function with given fields: sid, session
func (_m *Broker) CommitSession(sid string, session broker.Cacheable) error {
ret := _m.Called(sid, session)
var r0 error
if rf, ok := ret.Get(0).(func(string, broker.Cacheable) error); ok {
r0 = rf(sid, session)
} else {
r0 = ret.Error(0)
}
return r0
}
// FinishSession provides a mock function with given fields: sid
func (_m *Broker) FinishSession(sid string) error {
ret := _m.Called(sid)
var r0 error
if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(sid)
} else {
r0 = ret.Error(0)
}
return r0
}
// HandleBroadcast provides a mock function with given fields: msg
func (_m *Broker) HandleBroadcast(msg *common.StreamMessage) {
_m.Called(msg)
}
// HandleCommand provides a mock function with given fields: msg
func (_m *Broker) HandleCommand(msg *common.RemoteCommandMessage) {
_m.Called(msg)
}
// HistoryFrom provides a mock function with given fields: stream, epoch, offset
func (_m *Broker) HistoryFrom(stream string, epoch string, offset uint64) ([]common.StreamMessage, error) {
ret := _m.Called(stream, epoch, offset)
var r0 []common.StreamMessage
var r1 error
if rf, ok := ret.Get(0).(func(string, string, uint64) ([]common.StreamMessage, error)); ok {
return rf(stream, epoch, offset)
}
if rf, ok := ret.Get(0).(func(string, string, uint64) []common.StreamMessage); ok {
r0 = rf(stream, epoch, offset)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]common.StreamMessage)
}
}
if rf, ok := ret.Get(1).(func(string, string, uint64) error); ok {
r1 = rf(stream, epoch, offset)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// HistorySince provides a mock function with given fields: stream, ts
func (_m *Broker) HistorySince(stream string, ts int64) ([]common.StreamMessage, error) {
ret := _m.Called(stream, ts)
var r0 []common.StreamMessage
var r1 error
if rf, ok := ret.Get(0).(func(string, int64) ([]common.StreamMessage, error)); ok {
return rf(stream, ts)
}
if rf, ok := ret.Get(0).(func(string, int64) []common.StreamMessage); ok {
r0 = rf(stream, ts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]common.StreamMessage)
}
}
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
r1 = rf(stream, ts)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RestoreSession provides a mock function with given fields: from
func (_m *Broker) RestoreSession(from string) ([]byte, error) {
ret := _m.Called(from)
var r0 []byte
var r1 error
if rf, ok := ret.Get(0).(func(string) ([]byte, error)); ok {
return rf(from)
}
if rf, ok := ret.Get(0).(func(string) []byte); ok {
r0 = rf(from)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]byte)
}
}
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(from)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Shutdown provides a mock function with given fields: ctx
func (_m *Broker) Shutdown(ctx context.Context) error {
ret := _m.Called(ctx)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
} else {
r0 = ret.Error(0)
}
return r0
}
// Start provides a mock function with given fields: done
func (_m *Broker) Start(done chan error) error {
ret := _m.Called(done)
var r0 error
if rf, ok := ret.Get(0).(func(chan error) error); ok {
r0 = rf(done)
} else {
r0 = ret.Error(0)
}
return r0
}
// Subscribe provides a mock function with given fields: stream
func (_m *Broker) Subscribe(stream string) string {
ret := _m.Called(stream)
var r0 string
if rf, ok := ret.Get(0).(func(string) string); ok {
r0 = rf(stream)
} else {
r0 = ret.Get(0).(string)
}
return r0
}
// Unsubscribe provides a mock function with given fields: stream
func (_m *Broker) Unsubscribe(stream string) string {
ret := _m.Called(stream)
var r0 string
if rf, ok := ret.Get(0).(func(string) string); ok {
r0 = rf(stream)
} else {
r0 = ret.Get(0).(string)
}
return r0
}
type mockConstructorTestingTNewBroker interface {
mock.TestingT
Cleanup(func())
}
// NewBroker creates a new instance of Broker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewBroker(t mockConstructorTestingTNewBroker) *Broker {
mock := &Broker{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}