Consolidate operations on LocalNode. (#3140)
This commit is contained in:
@@ -165,7 +165,7 @@ func NewAgentService(conf *config.Config,
|
||||
Protocol: types.CurrentProtocol,
|
||||
AgentProtocol: agent.CurrentProtocol,
|
||||
Region: conf.Region,
|
||||
NodeId: currentNode.Id,
|
||||
NodeId: string(currentNode.NodeID()),
|
||||
}
|
||||
|
||||
agentServer, err := rpc.NewAgentInternalServer(s, bus)
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestCreateRoom(t *testing.T) {
|
||||
node, err := routing.NewLocalNode(conf)
|
||||
require.NoError(t, err)
|
||||
|
||||
ra, conf := newTestRoomAllocator(t, conf, node)
|
||||
ra, conf := newTestRoomAllocator(t, conf, node.Clone())
|
||||
|
||||
room, _, _, err := ra.CreateRoom(context.Background(), &livekit.CreateRoomRequest{Name: "myroom"}, true)
|
||||
require.NoError(t, err)
|
||||
@@ -55,10 +55,12 @@ func SelectRoomNode(t *testing.T) {
|
||||
|
||||
node, err := routing.NewLocalNode(conf)
|
||||
require.NoError(t, err)
|
||||
node.Stats.NumTracksIn = 100
|
||||
node.Stats.NumTracksOut = 100
|
||||
node.SetStats(&livekit.NodeStats{
|
||||
NumTracksIn: 100,
|
||||
NumTracksOut: 100,
|
||||
})
|
||||
|
||||
ra, _ := newTestRoomAllocator(t, conf, node)
|
||||
ra, _ := newTestRoomAllocator(t, conf, node.Clone())
|
||||
|
||||
err = ra.SelectRoomNode(context.Background(), "low-limit-room", "")
|
||||
require.ErrorIs(t, err, routing.ErrNodeLimitReached)
|
||||
@@ -71,10 +73,12 @@ func SelectRoomNode(t *testing.T) {
|
||||
|
||||
node, err := routing.NewLocalNode(conf)
|
||||
require.NoError(t, err)
|
||||
node.Stats.BytesInPerSec = 1000
|
||||
node.Stats.BytesOutPerSec = 1000
|
||||
node.SetStats(&livekit.NodeStats{
|
||||
BytesInPerSec: 1000,
|
||||
BytesOutPerSec: 1000,
|
||||
})
|
||||
|
||||
ra, _ := newTestRoomAllocator(t, conf, node)
|
||||
ra, _ := newTestRoomAllocator(t, conf, node.Clone())
|
||||
|
||||
err = ra.SelectRoomNode(context.Background(), "low-limit-room", "")
|
||||
require.ErrorIs(t, err, routing.ErrNodeLimitReached)
|
||||
|
||||
@@ -142,7 +142,7 @@ func NewLocalRoomManager(
|
||||
Protocol: types.CurrentProtocol,
|
||||
AgentProtocol: agent.CurrentProtocol,
|
||||
Region: conf.Region,
|
||||
NodeId: currentNode.Id,
|
||||
NodeId: string(currentNode.NodeID()),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func NewLocalRoomManager(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := r.roomManagerServer.RegisterAllNodeTopics(livekit.NodeID(currentNode.Id)); err != nil {
|
||||
if err := r.roomManagerServer.RegisterAllNodeTopics(currentNode.NodeID()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ func (r *RoomManager) StartSession(
|
||||
// It is possible that the client did not get that send request. So, send it again.
|
||||
logger.Infow("cannot restart a closed participant",
|
||||
"room", room.Name(),
|
||||
"nodeID", r.currentNode.Id,
|
||||
"nodeID", r.currentNode.NodeID(),
|
||||
"participant", pi.Identity,
|
||||
"reason", pi.ReconnectReason,
|
||||
)
|
||||
@@ -342,7 +342,7 @@ func (r *RoomManager) StartSession(
|
||||
}
|
||||
|
||||
participant.GetLogger().Infow("resuming RTC session",
|
||||
"nodeID", r.currentNode.Id,
|
||||
"nodeID", r.currentNode.NodeID(),
|
||||
"reason", pi.ReconnectReason,
|
||||
"numParticipants", room.GetParticipantCount(),
|
||||
)
|
||||
@@ -362,7 +362,7 @@ func (r *RoomManager) StartSession(
|
||||
participant.GetLogger().Warnw("could not resume participant", err)
|
||||
return err
|
||||
}
|
||||
r.telemetry.ParticipantResumed(ctx, room.ToProto(), participant.ToProto(), livekit.NodeID(r.currentNode.Id), pi.ReconnectReason)
|
||||
r.telemetry.ParticipantResumed(ctx, room.ToProto(), participant.ToProto(), r.currentNode.NodeID(), pi.ReconnectReason)
|
||||
go r.rtcSessionWorker(room, participant, requestSource)
|
||||
return nil
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func (r *RoomManager) StartSession(
|
||||
)
|
||||
pLogger.Infow("starting RTC session",
|
||||
"room", room.Name(),
|
||||
"nodeID", r.currentNode.Id,
|
||||
"nodeID", r.currentNode.NodeID(),
|
||||
"clientInfo", logger.Proto(pi.Client),
|
||||
"reconnect", pi.Reconnect,
|
||||
"reconnectReason", pi.ReconnectReason,
|
||||
@@ -532,7 +532,7 @@ func (r *RoomManager) StartSession(
|
||||
// update room store with new numParticipants
|
||||
persistRoomForParticipantCount(room.ToProto())
|
||||
|
||||
clientMeta := &livekit.AnalyticsClientMeta{Region: r.currentNode.Region, Node: r.currentNode.Id}
|
||||
clientMeta := &livekit.AnalyticsClientMeta{Region: r.currentNode.Region(), Node: string(r.currentNode.NodeID())}
|
||||
r.telemetry.ParticipantJoined(ctx, protoRoom, participant.ToProto(), pi.Client, clientMeta, true)
|
||||
participant.OnClose(func(p types.LocalParticipant) {
|
||||
killParticipantServer()
|
||||
|
||||
@@ -172,7 +172,7 @@ func NewLivekitServer(conf *config.Config,
|
||||
}
|
||||
|
||||
func (s *LivekitServer) Node() *livekit.Node {
|
||||
return s.currentNode
|
||||
return s.currentNode.Clone()
|
||||
}
|
||||
|
||||
func (s *LivekitServer) HTTPPort() int {
|
||||
@@ -232,8 +232,8 @@ func (s *LivekitServer) Start() error {
|
||||
|
||||
values := []interface{}{
|
||||
"portHttp", s.config.Port,
|
||||
"nodeID", s.currentNode.Id,
|
||||
"nodeIP", s.currentNode.Ip,
|
||||
"nodeID", s.currentNode.NodeID(),
|
||||
"nodeIP", s.currentNode.NodeIP(),
|
||||
"version", version.Version,
|
||||
}
|
||||
if s.config.BindAddresses != nil {
|
||||
|
||||
@@ -78,7 +78,7 @@ func NewDefaultSignalServer(
|
||||
router routing.Router,
|
||||
roomManager *RoomManager,
|
||||
) (r *SignalServer, err error) {
|
||||
return NewSignalServer(livekit.NodeID(currentNode.Id), currentNode.Region, bus, config, &defaultSessionHandler{currentNode, router, roomManager})
|
||||
return NewSignalServer(currentNode.NodeID(), currentNode.Region(), bus, config, &defaultSessionHandler{currentNode, router, roomManager})
|
||||
}
|
||||
|
||||
type defaultSessionHandler struct {
|
||||
@@ -105,7 +105,7 @@ func (s *defaultSessionHandler) HandleSession(
|
||||
return err
|
||||
}
|
||||
|
||||
if rtcNode.Id != s.currentNode.Id {
|
||||
if livekit.NodeID(rtcNode.Id) != s.currentNode.NodeID() {
|
||||
err = routing.ErrIncorrectRTCNode
|
||||
logger.Errorw("called participant on incorrect node", err,
|
||||
"rtcNode", rtcNode,
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ func InitializeRouter(conf *config.Config, currentNode routing.LocalNode) (routi
|
||||
}
|
||||
|
||||
func getNodeID(currentNode routing.LocalNode) livekit.NodeID {
|
||||
return livekit.NodeID(currentNode.Id)
|
||||
return currentNode.NodeID()
|
||||
}
|
||||
|
||||
func createKeyProvider(conf *config.Config) (auth.KeyProvider, error) {
|
||||
|
||||
@@ -183,7 +183,7 @@ func InitializeRouter(conf *config.Config, currentNode routing.LocalNode) (routi
|
||||
// wire.go:
|
||||
|
||||
func getNodeID(currentNode routing.LocalNode) livekit.NodeID {
|
||||
return livekit.NodeID(currentNode.Id)
|
||||
return currentNode.NodeID()
|
||||
}
|
||||
|
||||
func createKeyProvider(conf *config.Config) (auth.KeyProvider, error) {
|
||||
|
||||
Reference in New Issue
Block a user