- 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>
34 lines
1010 B
Go
34 lines
1010 B
Go
// Copyright (c) 2026 Winlin
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
package redisclient
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
// Use v8 because we use Go 1.16+, while v9 requires Go 1.18+
|
|
"github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
// RedisClient is the subset of *redis.Client methods used by callers in this
|
|
// codebase. Declared as an interface so tests can substitute a fake without
|
|
// standing up a real Redis server. *redis.Client satisfies this interface
|
|
// directly.
|
|
type RedisClient interface {
|
|
Ping(ctx context.Context) *redis.StatusCmd
|
|
Get(ctx context.Context, key string) *redis.StringCmd
|
|
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
|
|
String() string
|
|
}
|
|
|
|
// New connects to a Redis server at addr (host:port) with the given password
|
|
// and database index. Returns a RedisClient satisfied by *redis.Client.
|
|
func New(addr, password string, db int) RedisClient {
|
|
return redis.NewClient(&redis.Options{
|
|
Addr: addr,
|
|
Password: password,
|
|
DB: db,
|
|
})
|
|
}
|