mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 12:02:26 +00:00
Use the redis.UniversalClient interface instead of *redis.Client when interacting with go-redis (#1149)
* Use the redis.UniversalClient interface instead of *redis.Client when interacting with go-redis * Update protocol to v1.2.1
This commit is contained in:
1 parent
5a8a6d11b2
commit
c735668f67
8 files changed
+27
-28
No files matched your search
@@ -93,7 +93,7 @@ type MessageRouter interface {
|
||||
WriteRoomRTC(ctx context.Context, roomName livekit.RoomName, msg *livekit.RTCNodeMessage) error
|
||||
}
|
||||
|
||||
func CreateRouter(rc *redis.Client, node LocalNode) Router {
|
||||
func CreateRouter(rc redis.UniversalClient, node LocalNode) Router {
|
||||
if rc != nil {
|
||||
return NewRedisRouter(node, rc)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func signalNodeChannel(nodeID livekit.NodeID) string {
|
||||
return "signal_channel:" + string(nodeID)
|
||||
}
|
||||
|
||||
func publishRTCMessage(rc *redis.Client, nodeID livekit.NodeID, participantKey livekit.ParticipantKey, msg proto.Message) error {
|
||||
func publishRTCMessage(rc redis.UniversalClient, nodeID livekit.NodeID, participantKey livekit.ParticipantKey, msg proto.Message) error {
|
||||
rm := &livekit.RTCNodeMessage{
|
||||
ParticipantKey: string(participantKey),
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func publishRTCMessage(rc *redis.Client, nodeID livekit.NodeID, participantKey l
|
||||
return rc.Publish(redisCtx, rtcNodeChannel(nodeID), data).Err()
|
||||
}
|
||||
|
||||
func publishSignalMessage(rc *redis.Client, nodeID livekit.NodeID, connectionID livekit.ConnectionID, msg proto.Message) error {
|
||||
func publishSignalMessage(rc redis.UniversalClient, nodeID livekit.NodeID, connectionID livekit.ConnectionID, msg proto.Message) error {
|
||||
rm := &livekit.SignalNodeMessage{
|
||||
ConnectionId: string(connectionID),
|
||||
}
|
||||
@@ -94,14 +94,14 @@ func publishSignalMessage(rc *redis.Client, nodeID livekit.NodeID, connectionID
|
||||
}
|
||||
|
||||
type RTCNodeSink struct {
|
||||
rc *redis.Client
|
||||
rc redis.UniversalClient
|
||||
nodeID livekit.NodeID
|
||||
participantKey livekit.ParticipantKey
|
||||
isClosed atomic.Bool
|
||||
onClose func()
|
||||
}
|
||||
|
||||
func NewRTCNodeSink(rc *redis.Client, nodeID livekit.NodeID, participantKey livekit.ParticipantKey) *RTCNodeSink {
|
||||
func NewRTCNodeSink(rc redis.UniversalClient, nodeID livekit.NodeID, participantKey livekit.ParticipantKey) *RTCNodeSink {
|
||||
return &RTCNodeSink{
|
||||
rc: rc,
|
||||
nodeID: nodeID,
|
||||
@@ -130,14 +130,14 @@ func (s *RTCNodeSink) OnClose(f func()) {
|
||||
}
|
||||
|
||||
type SignalNodeSink struct {
|
||||
rc *redis.Client
|
||||
rc redis.UniversalClient
|
||||
nodeID livekit.NodeID
|
||||
connectionID livekit.ConnectionID
|
||||
isClosed atomic.Bool
|
||||
onClose func()
|
||||
}
|
||||
|
||||
func NewSignalNodeSink(rc *redis.Client, nodeID livekit.NodeID, connectionID livekit.ConnectionID) *SignalNodeSink {
|
||||
func NewSignalNodeSink(rc redis.UniversalClient, nodeID livekit.NodeID, connectionID livekit.ConnectionID) *SignalNodeSink {
|
||||
return &SignalNodeSink{
|
||||
rc: rc,
|
||||
nodeID: nodeID,
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
type RedisRouter struct {
|
||||
LocalRouter
|
||||
|
||||
rc *redis.Client
|
||||
rc redis.UniversalClient
|
||||
ctx context.Context
|
||||
isStarted atomic.Bool
|
||||
nodeMu sync.RWMutex
|
||||
@@ -44,7 +44,7 @@ type RedisRouter struct {
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func NewRedisRouter(currentNode LocalNode, rc *redis.Client) *RedisRouter {
|
||||
func NewRedisRouter(currentNode LocalNode, rc redis.UniversalClient) *RedisRouter {
|
||||
rr := &RedisRouter{
|
||||
LocalRouter: *NewLocalRouter(currentNode),
|
||||
rc: rc,
|
||||
|
||||
@@ -48,12 +48,12 @@ const (
|
||||
)
|
||||
|
||||
type RedisStore struct {
|
||||
rc *redis.Client
|
||||
rc redis.UniversalClient
|
||||
ctx context.Context
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
func NewRedisStore(rc *redis.Client) *RedisStore {
|
||||
func NewRedisStore(rc redis.UniversalClient) *RedisStore {
|
||||
return &RedisStore{
|
||||
ctx: context.Background(),
|
||||
rc: rc,
|
||||
|
||||
+3
-3
@@ -117,12 +117,12 @@ func createWebhookNotifier(conf *config.Config, provider auth.KeyProvider) (webh
|
||||
return webhook.NewNotifier(wc.APIKey, secret, wc.URLs), nil
|
||||
}
|
||||
|
||||
func createRedisClient(conf *config.Config) (*redis.Client, error) {
|
||||
func createRedisClient(conf *config.Config) (redis.UniversalClient, error) {
|
||||
if !conf.HasRedis() {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var rc *redis.Client
|
||||
var rc redis.UniversalClient
|
||||
var tlsConfig *tls.Config
|
||||
|
||||
if conf.Redis.UseTLS {
|
||||
@@ -167,7 +167,7 @@ func createRedisClient(conf *config.Config) (*redis.Client, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
func createStore(rc *redis.Client) ObjectStore {
|
||||
func createStore(rc redis.UniversalClient) ObjectStore {
|
||||
if rc != nil {
|
||||
return NewRedisStore(rc)
|
||||
}
|
||||
|
||||
+10
-10
@@ -35,18 +35,18 @@ import (
|
||||
|
||||
func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*LivekitServer, error) {
|
||||
roomConfig := getRoomConf(conf)
|
||||
client, err := createRedisClient(conf)
|
||||
universalClient, err := createRedisClient(conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := routing.CreateRouter(client, currentNode)
|
||||
objectStore := createStore(client)
|
||||
router := routing.CreateRouter(universalClient, currentNode)
|
||||
objectStore := createStore(universalClient)
|
||||
roomAllocator, err := NewRoomAllocator(conf, router, objectStore)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nodeID := getNodeID(currentNode)
|
||||
rpcClient := egress.NewRedisRPCClient(nodeID, client)
|
||||
rpcClient := egress.NewRedisRPCClient(nodeID, universalClient)
|
||||
egressStore := getEgressStore(objectStore)
|
||||
keyProvider, err := createKeyProvider(conf)
|
||||
if err != nil {
|
||||
@@ -65,7 +65,7 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
}
|
||||
egressService := NewEgressService(rpcClient, objectStore, egressStore, roomService, telemetryService, rtcEgressLauncher)
|
||||
ingressConfig := getIngressConfig(conf)
|
||||
rpc := ingress.NewRedisRPC(nodeID, client)
|
||||
rpc := ingress.NewRedisRPC(nodeID, universalClient)
|
||||
ingressRPCClient := getIngressRPCClient(rpc)
|
||||
ingressStore := getIngressStore(objectStore)
|
||||
ingressService := NewIngressService(ingressConfig, ingressRPCClient, ingressStore, roomService, telemetryService)
|
||||
@@ -88,11 +88,11 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
}
|
||||
|
||||
func InitializeRouter(conf *config.Config, currentNode routing.LocalNode) (routing.Router, error) {
|
||||
client, err := createRedisClient(conf)
|
||||
universalClient, err := createRedisClient(conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := routing.CreateRouter(client, currentNode)
|
||||
router := routing.CreateRouter(universalClient, currentNode)
|
||||
return router, nil
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ func createWebhookNotifier(conf *config.Config, provider auth.KeyProvider) (webh
|
||||
return webhook.NewNotifier(wc.APIKey, secret, wc.URLs), nil
|
||||
}
|
||||
|
||||
func createRedisClient(conf *config.Config) (*redis.Client, error) {
|
||||
func createRedisClient(conf *config.Config) (redis.UniversalClient, error) {
|
||||
if !conf.HasRedis() {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var rc *redis.Client
|
||||
var rc redis.UniversalClient
|
||||
var tlsConfig *tls.Config
|
||||
|
||||
if conf.Redis.UseTLS {
|
||||
@@ -193,7 +193,7 @@ func createRedisClient(conf *config.Config) (*redis.Client, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
func createStore(rc *redis.Client) ObjectStore {
|
||||
func createStore(rc redis.UniversalClient) ObjectStore {
|
||||
if rc != nil {
|
||||
return NewRedisStore(rc)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user