github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/rpc/rpcfakes/fake_keepalive_pub_sub.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package rpcfakes 3 4 import ( 5 "context" 6 "sync" 7 8 "github.com/livekit/protocol/livekit" 9 "github.com/livekit/protocol/rpc" 10 "github.com/livekit/psrpc" 11 ) 12 13 type FakeKeepalivePubSub struct { 14 KillStub func() 15 killMutex sync.RWMutex 16 killArgsForCall []struct { 17 } 18 PublishPingStub func(context.Context, livekit.NodeID, *rpc.KeepalivePing) error 19 publishPingMutex sync.RWMutex 20 publishPingArgsForCall []struct { 21 arg1 context.Context 22 arg2 livekit.NodeID 23 arg3 *rpc.KeepalivePing 24 } 25 publishPingReturns struct { 26 result1 error 27 } 28 publishPingReturnsOnCall map[int]struct { 29 result1 error 30 } 31 ShutdownStub func() 32 shutdownMutex sync.RWMutex 33 shutdownArgsForCall []struct { 34 } 35 SubscribePingStub func(context.Context, livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error) 36 subscribePingMutex sync.RWMutex 37 subscribePingArgsForCall []struct { 38 arg1 context.Context 39 arg2 livekit.NodeID 40 } 41 subscribePingReturns struct { 42 result1 psrpc.Subscription[*rpc.KeepalivePing] 43 result2 error 44 } 45 subscribePingReturnsOnCall map[int]struct { 46 result1 psrpc.Subscription[*rpc.KeepalivePing] 47 result2 error 48 } 49 invocations map[string][][]interface{} 50 invocationsMutex sync.RWMutex 51 } 52 53 func (fake *FakeKeepalivePubSub) Kill() { 54 fake.killMutex.Lock() 55 fake.killArgsForCall = append(fake.killArgsForCall, struct { 56 }{}) 57 stub := fake.KillStub 58 fake.recordInvocation("Kill", []interface{}{}) 59 fake.killMutex.Unlock() 60 if stub != nil { 61 fake.KillStub() 62 } 63 } 64 65 func (fake *FakeKeepalivePubSub) KillCallCount() int { 66 fake.killMutex.RLock() 67 defer fake.killMutex.RUnlock() 68 return len(fake.killArgsForCall) 69 } 70 71 func (fake *FakeKeepalivePubSub) KillCalls(stub func()) { 72 fake.killMutex.Lock() 73 defer fake.killMutex.Unlock() 74 fake.KillStub = stub 75 } 76 77 func (fake *FakeKeepalivePubSub) PublishPing(arg1 context.Context, arg2 livekit.NodeID, arg3 *rpc.KeepalivePing) error { 78 fake.publishPingMutex.Lock() 79 ret, specificReturn := fake.publishPingReturnsOnCall[len(fake.publishPingArgsForCall)] 80 fake.publishPingArgsForCall = append(fake.publishPingArgsForCall, struct { 81 arg1 context.Context 82 arg2 livekit.NodeID 83 arg3 *rpc.KeepalivePing 84 }{arg1, arg2, arg3}) 85 stub := fake.PublishPingStub 86 fakeReturns := fake.publishPingReturns 87 fake.recordInvocation("PublishPing", []interface{}{arg1, arg2, arg3}) 88 fake.publishPingMutex.Unlock() 89 if stub != nil { 90 return stub(arg1, arg2, arg3) 91 } 92 if specificReturn { 93 return ret.result1 94 } 95 return fakeReturns.result1 96 } 97 98 func (fake *FakeKeepalivePubSub) PublishPingCallCount() int { 99 fake.publishPingMutex.RLock() 100 defer fake.publishPingMutex.RUnlock() 101 return len(fake.publishPingArgsForCall) 102 } 103 104 func (fake *FakeKeepalivePubSub) PublishPingCalls(stub func(context.Context, livekit.NodeID, *rpc.KeepalivePing) error) { 105 fake.publishPingMutex.Lock() 106 defer fake.publishPingMutex.Unlock() 107 fake.PublishPingStub = stub 108 } 109 110 func (fake *FakeKeepalivePubSub) PublishPingArgsForCall(i int) (context.Context, livekit.NodeID, *rpc.KeepalivePing) { 111 fake.publishPingMutex.RLock() 112 defer fake.publishPingMutex.RUnlock() 113 argsForCall := fake.publishPingArgsForCall[i] 114 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 115 } 116 117 func (fake *FakeKeepalivePubSub) PublishPingReturns(result1 error) { 118 fake.publishPingMutex.Lock() 119 defer fake.publishPingMutex.Unlock() 120 fake.PublishPingStub = nil 121 fake.publishPingReturns = struct { 122 result1 error 123 }{result1} 124 } 125 126 func (fake *FakeKeepalivePubSub) PublishPingReturnsOnCall(i int, result1 error) { 127 fake.publishPingMutex.Lock() 128 defer fake.publishPingMutex.Unlock() 129 fake.PublishPingStub = nil 130 if fake.publishPingReturnsOnCall == nil { 131 fake.publishPingReturnsOnCall = make(map[int]struct { 132 result1 error 133 }) 134 } 135 fake.publishPingReturnsOnCall[i] = struct { 136 result1 error 137 }{result1} 138 } 139 140 func (fake *FakeKeepalivePubSub) Shutdown() { 141 fake.shutdownMutex.Lock() 142 fake.shutdownArgsForCall = append(fake.shutdownArgsForCall, struct { 143 }{}) 144 stub := fake.ShutdownStub 145 fake.recordInvocation("Shutdown", []interface{}{}) 146 fake.shutdownMutex.Unlock() 147 if stub != nil { 148 fake.ShutdownStub() 149 } 150 } 151 152 func (fake *FakeKeepalivePubSub) ShutdownCallCount() int { 153 fake.shutdownMutex.RLock() 154 defer fake.shutdownMutex.RUnlock() 155 return len(fake.shutdownArgsForCall) 156 } 157 158 func (fake *FakeKeepalivePubSub) ShutdownCalls(stub func()) { 159 fake.shutdownMutex.Lock() 160 defer fake.shutdownMutex.Unlock() 161 fake.ShutdownStub = stub 162 } 163 164 func (fake *FakeKeepalivePubSub) SubscribePing(arg1 context.Context, arg2 livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error) { 165 fake.subscribePingMutex.Lock() 166 ret, specificReturn := fake.subscribePingReturnsOnCall[len(fake.subscribePingArgsForCall)] 167 fake.subscribePingArgsForCall = append(fake.subscribePingArgsForCall, struct { 168 arg1 context.Context 169 arg2 livekit.NodeID 170 }{arg1, arg2}) 171 stub := fake.SubscribePingStub 172 fakeReturns := fake.subscribePingReturns 173 fake.recordInvocation("SubscribePing", []interface{}{arg1, arg2}) 174 fake.subscribePingMutex.Unlock() 175 if stub != nil { 176 return stub(arg1, arg2) 177 } 178 if specificReturn { 179 return ret.result1, ret.result2 180 } 181 return fakeReturns.result1, fakeReturns.result2 182 } 183 184 func (fake *FakeKeepalivePubSub) SubscribePingCallCount() int { 185 fake.subscribePingMutex.RLock() 186 defer fake.subscribePingMutex.RUnlock() 187 return len(fake.subscribePingArgsForCall) 188 } 189 190 func (fake *FakeKeepalivePubSub) SubscribePingCalls(stub func(context.Context, livekit.NodeID) (psrpc.Subscription[*rpc.KeepalivePing], error)) { 191 fake.subscribePingMutex.Lock() 192 defer fake.subscribePingMutex.Unlock() 193 fake.SubscribePingStub = stub 194 } 195 196 func (fake *FakeKeepalivePubSub) SubscribePingArgsForCall(i int) (context.Context, livekit.NodeID) { 197 fake.subscribePingMutex.RLock() 198 defer fake.subscribePingMutex.RUnlock() 199 argsForCall := fake.subscribePingArgsForCall[i] 200 return argsForCall.arg1, argsForCall.arg2 201 } 202 203 func (fake *FakeKeepalivePubSub) SubscribePingReturns(result1 psrpc.Subscription[*rpc.KeepalivePing], result2 error) { 204 fake.subscribePingMutex.Lock() 205 defer fake.subscribePingMutex.Unlock() 206 fake.SubscribePingStub = nil 207 fake.subscribePingReturns = struct { 208 result1 psrpc.Subscription[*rpc.KeepalivePing] 209 result2 error 210 }{result1, result2} 211 } 212 213 func (fake *FakeKeepalivePubSub) SubscribePingReturnsOnCall(i int, result1 psrpc.Subscription[*rpc.KeepalivePing], result2 error) { 214 fake.subscribePingMutex.Lock() 215 defer fake.subscribePingMutex.Unlock() 216 fake.SubscribePingStub = nil 217 if fake.subscribePingReturnsOnCall == nil { 218 fake.subscribePingReturnsOnCall = make(map[int]struct { 219 result1 psrpc.Subscription[*rpc.KeepalivePing] 220 result2 error 221 }) 222 } 223 fake.subscribePingReturnsOnCall[i] = struct { 224 result1 psrpc.Subscription[*rpc.KeepalivePing] 225 result2 error 226 }{result1, result2} 227 } 228 229 func (fake *FakeKeepalivePubSub) Invocations() map[string][][]interface{} { 230 fake.invocationsMutex.RLock() 231 defer fake.invocationsMutex.RUnlock() 232 fake.killMutex.RLock() 233 defer fake.killMutex.RUnlock() 234 fake.publishPingMutex.RLock() 235 defer fake.publishPingMutex.RUnlock() 236 fake.shutdownMutex.RLock() 237 defer fake.shutdownMutex.RUnlock() 238 fake.subscribePingMutex.RLock() 239 defer fake.subscribePingMutex.RUnlock() 240 copiedInvocations := map[string][][]interface{}{} 241 for key, value := range fake.invocations { 242 copiedInvocations[key] = value 243 } 244 return copiedInvocations 245 } 246 247 func (fake *FakeKeepalivePubSub) recordInvocation(key string, args []interface{}) { 248 fake.invocationsMutex.Lock() 249 defer fake.invocationsMutex.Unlock() 250 if fake.invocations == nil { 251 fake.invocations = map[string][][]interface{}{} 252 } 253 if fake.invocations[key] == nil { 254 fake.invocations[key] = [][]interface{}{} 255 } 256 fake.invocations[key] = append(fake.invocations[key], args) 257 } 258 259 var _ rpc.KeepalivePubSub = new(FakeKeepalivePubSub)