mirror of
https://github.com/livekit/livekit.git
synced 2026-09-01 20:09:08 +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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user