- Split OriginLoadBalancer into OriginService / HLSService / RTCService; the original interface now embeds the three role interfaces. Generate counterfeiter fakes for all four. - Extract internal/redisclient: RedisClient interface + New() factory. internal/lb/redis.go no longer imports github.com/go-redis/redis/v8. - Add unit tests for lb.go (OriginServer.ID/String/Format/NewOriginServer) and for the full memory + redis load balancers. - Replace package-level test seams (memoryKeepaliveInterval, newRedisClient, redisKeepaliveInterval, signal.signalNotify/osExit, rtmp.createBuffer) with per-instance struct fields so concurrent tests can't race on them. - Promote signal.InstallSignals / InstallForceQuit onto a new signal.Handler type; update bootstrap to construct one. - Move rtmp createBuffer onto amf0ObjectBase as bufFactory; the three AMF0 marshalers and their tests use the per-instance factory. - Make proxy test scripts locate the workspace by walking up to go.mod instead of brittle '../../../..' counting (symlink-aware). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
328 lines
8.3 KiB
Go
328 lines
8.3 KiB
Go
// Code generated by counterfeiter. DO NOT EDIT.
|
|
package redisclientfakes
|
|
|
|
import (
|
|
"context"
|
|
"srsx/internal/redisclient"
|
|
"sync"
|
|
"time"
|
|
|
|
redis "github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
type FakeRedisClient struct {
|
|
GetStub func(context.Context, string) *redis.StringCmd
|
|
getMutex sync.RWMutex
|
|
getArgsForCall []struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
}
|
|
getReturns struct {
|
|
result1 *redis.StringCmd
|
|
}
|
|
getReturnsOnCall map[int]struct {
|
|
result1 *redis.StringCmd
|
|
}
|
|
PingStub func(context.Context) *redis.StatusCmd
|
|
pingMutex sync.RWMutex
|
|
pingArgsForCall []struct {
|
|
arg1 context.Context
|
|
}
|
|
pingReturns struct {
|
|
result1 *redis.StatusCmd
|
|
}
|
|
pingReturnsOnCall map[int]struct {
|
|
result1 *redis.StatusCmd
|
|
}
|
|
SetStub func(context.Context, string, interface{}, time.Duration) *redis.StatusCmd
|
|
setMutex sync.RWMutex
|
|
setArgsForCall []struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
arg3 interface{}
|
|
arg4 time.Duration
|
|
}
|
|
setReturns struct {
|
|
result1 *redis.StatusCmd
|
|
}
|
|
setReturnsOnCall map[int]struct {
|
|
result1 *redis.StatusCmd
|
|
}
|
|
StringStub func() string
|
|
stringMutex sync.RWMutex
|
|
stringArgsForCall []struct {
|
|
}
|
|
stringReturns struct {
|
|
result1 string
|
|
}
|
|
stringReturnsOnCall map[int]struct {
|
|
result1 string
|
|
}
|
|
invocations map[string][][]interface{}
|
|
invocationsMutex sync.RWMutex
|
|
}
|
|
|
|
func (fake *FakeRedisClient) Get(arg1 context.Context, arg2 string) *redis.StringCmd {
|
|
fake.getMutex.Lock()
|
|
ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)]
|
|
fake.getArgsForCall = append(fake.getArgsForCall, struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
}{arg1, arg2})
|
|
stub := fake.GetStub
|
|
fakeReturns := fake.getReturns
|
|
fake.recordInvocation("Get", []interface{}{arg1, arg2})
|
|
fake.getMutex.Unlock()
|
|
if stub != nil {
|
|
return stub(arg1, arg2)
|
|
}
|
|
if specificReturn {
|
|
return ret.result1
|
|
}
|
|
return fakeReturns.result1
|
|
}
|
|
|
|
func (fake *FakeRedisClient) GetCallCount() int {
|
|
fake.getMutex.RLock()
|
|
defer fake.getMutex.RUnlock()
|
|
return len(fake.getArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeRedisClient) GetCalls(stub func(context.Context, string) *redis.StringCmd) {
|
|
fake.getMutex.Lock()
|
|
defer fake.getMutex.Unlock()
|
|
fake.GetStub = stub
|
|
}
|
|
|
|
func (fake *FakeRedisClient) GetArgsForCall(i int) (context.Context, string) {
|
|
fake.getMutex.RLock()
|
|
defer fake.getMutex.RUnlock()
|
|
argsForCall := fake.getArgsForCall[i]
|
|
return argsForCall.arg1, argsForCall.arg2
|
|
}
|
|
|
|
func (fake *FakeRedisClient) GetReturns(result1 *redis.StringCmd) {
|
|
fake.getMutex.Lock()
|
|
defer fake.getMutex.Unlock()
|
|
fake.GetStub = nil
|
|
fake.getReturns = struct {
|
|
result1 *redis.StringCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) GetReturnsOnCall(i int, result1 *redis.StringCmd) {
|
|
fake.getMutex.Lock()
|
|
defer fake.getMutex.Unlock()
|
|
fake.GetStub = nil
|
|
if fake.getReturnsOnCall == nil {
|
|
fake.getReturnsOnCall = make(map[int]struct {
|
|
result1 *redis.StringCmd
|
|
})
|
|
}
|
|
fake.getReturnsOnCall[i] = struct {
|
|
result1 *redis.StringCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) Ping(arg1 context.Context) *redis.StatusCmd {
|
|
fake.pingMutex.Lock()
|
|
ret, specificReturn := fake.pingReturnsOnCall[len(fake.pingArgsForCall)]
|
|
fake.pingArgsForCall = append(fake.pingArgsForCall, struct {
|
|
arg1 context.Context
|
|
}{arg1})
|
|
stub := fake.PingStub
|
|
fakeReturns := fake.pingReturns
|
|
fake.recordInvocation("Ping", []interface{}{arg1})
|
|
fake.pingMutex.Unlock()
|
|
if stub != nil {
|
|
return stub(arg1)
|
|
}
|
|
if specificReturn {
|
|
return ret.result1
|
|
}
|
|
return fakeReturns.result1
|
|
}
|
|
|
|
func (fake *FakeRedisClient) PingCallCount() int {
|
|
fake.pingMutex.RLock()
|
|
defer fake.pingMutex.RUnlock()
|
|
return len(fake.pingArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeRedisClient) PingCalls(stub func(context.Context) *redis.StatusCmd) {
|
|
fake.pingMutex.Lock()
|
|
defer fake.pingMutex.Unlock()
|
|
fake.PingStub = stub
|
|
}
|
|
|
|
func (fake *FakeRedisClient) PingArgsForCall(i int) context.Context {
|
|
fake.pingMutex.RLock()
|
|
defer fake.pingMutex.RUnlock()
|
|
argsForCall := fake.pingArgsForCall[i]
|
|
return argsForCall.arg1
|
|
}
|
|
|
|
func (fake *FakeRedisClient) PingReturns(result1 *redis.StatusCmd) {
|
|
fake.pingMutex.Lock()
|
|
defer fake.pingMutex.Unlock()
|
|
fake.PingStub = nil
|
|
fake.pingReturns = struct {
|
|
result1 *redis.StatusCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) PingReturnsOnCall(i int, result1 *redis.StatusCmd) {
|
|
fake.pingMutex.Lock()
|
|
defer fake.pingMutex.Unlock()
|
|
fake.PingStub = nil
|
|
if fake.pingReturnsOnCall == nil {
|
|
fake.pingReturnsOnCall = make(map[int]struct {
|
|
result1 *redis.StatusCmd
|
|
})
|
|
}
|
|
fake.pingReturnsOnCall[i] = struct {
|
|
result1 *redis.StatusCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) Set(arg1 context.Context, arg2 string, arg3 interface{}, arg4 time.Duration) *redis.StatusCmd {
|
|
fake.setMutex.Lock()
|
|
ret, specificReturn := fake.setReturnsOnCall[len(fake.setArgsForCall)]
|
|
fake.setArgsForCall = append(fake.setArgsForCall, struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
arg3 interface{}
|
|
arg4 time.Duration
|
|
}{arg1, arg2, arg3, arg4})
|
|
stub := fake.SetStub
|
|
fakeReturns := fake.setReturns
|
|
fake.recordInvocation("Set", []interface{}{arg1, arg2, arg3, arg4})
|
|
fake.setMutex.Unlock()
|
|
if stub != nil {
|
|
return stub(arg1, arg2, arg3, arg4)
|
|
}
|
|
if specificReturn {
|
|
return ret.result1
|
|
}
|
|
return fakeReturns.result1
|
|
}
|
|
|
|
func (fake *FakeRedisClient) SetCallCount() int {
|
|
fake.setMutex.RLock()
|
|
defer fake.setMutex.RUnlock()
|
|
return len(fake.setArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeRedisClient) SetCalls(stub func(context.Context, string, interface{}, time.Duration) *redis.StatusCmd) {
|
|
fake.setMutex.Lock()
|
|
defer fake.setMutex.Unlock()
|
|
fake.SetStub = stub
|
|
}
|
|
|
|
func (fake *FakeRedisClient) SetArgsForCall(i int) (context.Context, string, interface{}, time.Duration) {
|
|
fake.setMutex.RLock()
|
|
defer fake.setMutex.RUnlock()
|
|
argsForCall := fake.setArgsForCall[i]
|
|
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
|
|
}
|
|
|
|
func (fake *FakeRedisClient) SetReturns(result1 *redis.StatusCmd) {
|
|
fake.setMutex.Lock()
|
|
defer fake.setMutex.Unlock()
|
|
fake.SetStub = nil
|
|
fake.setReturns = struct {
|
|
result1 *redis.StatusCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) SetReturnsOnCall(i int, result1 *redis.StatusCmd) {
|
|
fake.setMutex.Lock()
|
|
defer fake.setMutex.Unlock()
|
|
fake.SetStub = nil
|
|
if fake.setReturnsOnCall == nil {
|
|
fake.setReturnsOnCall = make(map[int]struct {
|
|
result1 *redis.StatusCmd
|
|
})
|
|
}
|
|
fake.setReturnsOnCall[i] = struct {
|
|
result1 *redis.StatusCmd
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) String() string {
|
|
fake.stringMutex.Lock()
|
|
ret, specificReturn := fake.stringReturnsOnCall[len(fake.stringArgsForCall)]
|
|
fake.stringArgsForCall = append(fake.stringArgsForCall, struct {
|
|
}{})
|
|
stub := fake.StringStub
|
|
fakeReturns := fake.stringReturns
|
|
fake.recordInvocation("String", []interface{}{})
|
|
fake.stringMutex.Unlock()
|
|
if stub != nil {
|
|
return stub()
|
|
}
|
|
if specificReturn {
|
|
return ret.result1
|
|
}
|
|
return fakeReturns.result1
|
|
}
|
|
|
|
func (fake *FakeRedisClient) StringCallCount() int {
|
|
fake.stringMutex.RLock()
|
|
defer fake.stringMutex.RUnlock()
|
|
return len(fake.stringArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeRedisClient) StringCalls(stub func() string) {
|
|
fake.stringMutex.Lock()
|
|
defer fake.stringMutex.Unlock()
|
|
fake.StringStub = stub
|
|
}
|
|
|
|
func (fake *FakeRedisClient) StringReturns(result1 string) {
|
|
fake.stringMutex.Lock()
|
|
defer fake.stringMutex.Unlock()
|
|
fake.StringStub = nil
|
|
fake.stringReturns = struct {
|
|
result1 string
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) StringReturnsOnCall(i int, result1 string) {
|
|
fake.stringMutex.Lock()
|
|
defer fake.stringMutex.Unlock()
|
|
fake.StringStub = nil
|
|
if fake.stringReturnsOnCall == nil {
|
|
fake.stringReturnsOnCall = make(map[int]struct {
|
|
result1 string
|
|
})
|
|
}
|
|
fake.stringReturnsOnCall[i] = struct {
|
|
result1 string
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeRedisClient) Invocations() map[string][][]interface{} {
|
|
fake.invocationsMutex.RLock()
|
|
defer fake.invocationsMutex.RUnlock()
|
|
copiedInvocations := map[string][][]interface{}{}
|
|
for key, value := range fake.invocations {
|
|
copiedInvocations[key] = value
|
|
}
|
|
return copiedInvocations
|
|
}
|
|
|
|
func (fake *FakeRedisClient) recordInvocation(key string, args []interface{}) {
|
|
fake.invocationsMutex.Lock()
|
|
defer fake.invocationsMutex.Unlock()
|
|
if fake.invocations == nil {
|
|
fake.invocations = map[string][][]interface{}{}
|
|
}
|
|
if fake.invocations[key] == nil {
|
|
fake.invocations[key] = [][]interface{}{}
|
|
}
|
|
fake.invocations[key] = append(fake.invocations[key], args)
|
|
}
|
|
|
|
var _ redisclient.RedisClient = new(FakeRedisClient)
|