- 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>
191 lines
5.0 KiB
Go
191 lines
5.0 KiB
Go
// Code generated by counterfeiter. DO NOT EDIT.
|
|
package lbfakes
|
|
|
|
import (
|
|
"context"
|
|
"srsx/internal/lb"
|
|
"sync"
|
|
)
|
|
|
|
type FakeOriginService struct {
|
|
PickStub func(context.Context, string) (*lb.OriginServer, error)
|
|
pickMutex sync.RWMutex
|
|
pickArgsForCall []struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
}
|
|
pickReturns struct {
|
|
result1 *lb.OriginServer
|
|
result2 error
|
|
}
|
|
pickReturnsOnCall map[int]struct {
|
|
result1 *lb.OriginServer
|
|
result2 error
|
|
}
|
|
UpdateStub func(context.Context, *lb.OriginServer) error
|
|
updateMutex sync.RWMutex
|
|
updateArgsForCall []struct {
|
|
arg1 context.Context
|
|
arg2 *lb.OriginServer
|
|
}
|
|
updateReturns struct {
|
|
result1 error
|
|
}
|
|
updateReturnsOnCall map[int]struct {
|
|
result1 error
|
|
}
|
|
invocations map[string][][]interface{}
|
|
invocationsMutex sync.RWMutex
|
|
}
|
|
|
|
func (fake *FakeOriginService) Pick(arg1 context.Context, arg2 string) (*lb.OriginServer, error) {
|
|
fake.pickMutex.Lock()
|
|
ret, specificReturn := fake.pickReturnsOnCall[len(fake.pickArgsForCall)]
|
|
fake.pickArgsForCall = append(fake.pickArgsForCall, struct {
|
|
arg1 context.Context
|
|
arg2 string
|
|
}{arg1, arg2})
|
|
stub := fake.PickStub
|
|
fakeReturns := fake.pickReturns
|
|
fake.recordInvocation("Pick", []interface{}{arg1, arg2})
|
|
fake.pickMutex.Unlock()
|
|
if stub != nil {
|
|
return stub(arg1, arg2)
|
|
}
|
|
if specificReturn {
|
|
return ret.result1, ret.result2
|
|
}
|
|
return fakeReturns.result1, fakeReturns.result2
|
|
}
|
|
|
|
func (fake *FakeOriginService) PickCallCount() int {
|
|
fake.pickMutex.RLock()
|
|
defer fake.pickMutex.RUnlock()
|
|
return len(fake.pickArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeOriginService) PickCalls(stub func(context.Context, string) (*lb.OriginServer, error)) {
|
|
fake.pickMutex.Lock()
|
|
defer fake.pickMutex.Unlock()
|
|
fake.PickStub = stub
|
|
}
|
|
|
|
func (fake *FakeOriginService) PickArgsForCall(i int) (context.Context, string) {
|
|
fake.pickMutex.RLock()
|
|
defer fake.pickMutex.RUnlock()
|
|
argsForCall := fake.pickArgsForCall[i]
|
|
return argsForCall.arg1, argsForCall.arg2
|
|
}
|
|
|
|
func (fake *FakeOriginService) PickReturns(result1 *lb.OriginServer, result2 error) {
|
|
fake.pickMutex.Lock()
|
|
defer fake.pickMutex.Unlock()
|
|
fake.PickStub = nil
|
|
fake.pickReturns = struct {
|
|
result1 *lb.OriginServer
|
|
result2 error
|
|
}{result1, result2}
|
|
}
|
|
|
|
func (fake *FakeOriginService) PickReturnsOnCall(i int, result1 *lb.OriginServer, result2 error) {
|
|
fake.pickMutex.Lock()
|
|
defer fake.pickMutex.Unlock()
|
|
fake.PickStub = nil
|
|
if fake.pickReturnsOnCall == nil {
|
|
fake.pickReturnsOnCall = make(map[int]struct {
|
|
result1 *lb.OriginServer
|
|
result2 error
|
|
})
|
|
}
|
|
fake.pickReturnsOnCall[i] = struct {
|
|
result1 *lb.OriginServer
|
|
result2 error
|
|
}{result1, result2}
|
|
}
|
|
|
|
func (fake *FakeOriginService) Update(arg1 context.Context, arg2 *lb.OriginServer) error {
|
|
fake.updateMutex.Lock()
|
|
ret, specificReturn := fake.updateReturnsOnCall[len(fake.updateArgsForCall)]
|
|
fake.updateArgsForCall = append(fake.updateArgsForCall, struct {
|
|
arg1 context.Context
|
|
arg2 *lb.OriginServer
|
|
}{arg1, arg2})
|
|
stub := fake.UpdateStub
|
|
fakeReturns := fake.updateReturns
|
|
fake.recordInvocation("Update", []interface{}{arg1, arg2})
|
|
fake.updateMutex.Unlock()
|
|
if stub != nil {
|
|
return stub(arg1, arg2)
|
|
}
|
|
if specificReturn {
|
|
return ret.result1
|
|
}
|
|
return fakeReturns.result1
|
|
}
|
|
|
|
func (fake *FakeOriginService) UpdateCallCount() int {
|
|
fake.updateMutex.RLock()
|
|
defer fake.updateMutex.RUnlock()
|
|
return len(fake.updateArgsForCall)
|
|
}
|
|
|
|
func (fake *FakeOriginService) UpdateCalls(stub func(context.Context, *lb.OriginServer) error) {
|
|
fake.updateMutex.Lock()
|
|
defer fake.updateMutex.Unlock()
|
|
fake.UpdateStub = stub
|
|
}
|
|
|
|
func (fake *FakeOriginService) UpdateArgsForCall(i int) (context.Context, *lb.OriginServer) {
|
|
fake.updateMutex.RLock()
|
|
defer fake.updateMutex.RUnlock()
|
|
argsForCall := fake.updateArgsForCall[i]
|
|
return argsForCall.arg1, argsForCall.arg2
|
|
}
|
|
|
|
func (fake *FakeOriginService) UpdateReturns(result1 error) {
|
|
fake.updateMutex.Lock()
|
|
defer fake.updateMutex.Unlock()
|
|
fake.UpdateStub = nil
|
|
fake.updateReturns = struct {
|
|
result1 error
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeOriginService) UpdateReturnsOnCall(i int, result1 error) {
|
|
fake.updateMutex.Lock()
|
|
defer fake.updateMutex.Unlock()
|
|
fake.UpdateStub = nil
|
|
if fake.updateReturnsOnCall == nil {
|
|
fake.updateReturnsOnCall = make(map[int]struct {
|
|
result1 error
|
|
})
|
|
}
|
|
fake.updateReturnsOnCall[i] = struct {
|
|
result1 error
|
|
}{result1}
|
|
}
|
|
|
|
func (fake *FakeOriginService) 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 *FakeOriginService) 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 _ lb.OriginService = new(FakeOriginService)
|