Better tracking of signalling connection. (#1794)

* Better tracking of signalling connection.

- Reason for closing signaling channel.
- ConnectionID attached to request source/response sink

* Tests
This commit is contained in:
Raja Subramanian
2023-06-15 12:53:34 +05:30
committed by GitHub
parent 41bb1d8745
commit 12db469297
18 changed files with 275 additions and 49 deletions
+14 -7
View File
@@ -3,24 +3,27 @@ package routing
import (
"sync"
"github.com/livekit/protocol/livekit"
"google.golang.org/protobuf/proto"
)
const DefaultMessageChannelSize = 200
type MessageChannel struct {
msgChan chan proto.Message
onClose func()
isClosed bool
lock sync.RWMutex
connectionID livekit.ConnectionID
msgChan chan proto.Message
onClose func()
isClosed bool
lock sync.RWMutex
}
func NewDefaultMessageChannel() *MessageChannel {
return NewMessageChannel(DefaultMessageChannelSize)
func NewDefaultMessageChannel(connectionID livekit.ConnectionID) *MessageChannel {
return NewMessageChannel(connectionID, DefaultMessageChannelSize)
}
func NewMessageChannel(size int) *MessageChannel {
func NewMessageChannel(connectionID livekit.ConnectionID, size int) *MessageChannel {
return &MessageChannel{
connectionID: connectionID,
// allow some buffer to avoid blocked writes
msgChan: make(chan proto.Message, size),
}
@@ -71,3 +74,7 @@ func (m *MessageChannel) Close() {
m.onClose()
}
}
func (m *MessageChannel) ConnectionID() livekit.ConnectionID {
return m.connectionID
}