Instantiate default agent dispatches in rtc for better backward compatibility (#2886)
This commit is contained in:
+11
-1
@@ -122,7 +122,11 @@ func (c *agentClient) LaunchJob(ctx context.Context, desc *JobRequest) *serverut
|
|||||||
dispatcher := c.getDispatcher(desc.AgentName, desc.JobType)
|
dispatcher := c.getDispatcher(desc.AgentName, desc.JobType)
|
||||||
|
|
||||||
if dispatcher == nil {
|
if dispatcher == nil {
|
||||||
logger.Infow("not dispatching agent job since no worker is available", "agentName", desc.AgentName, "jobType", desc.JobType)
|
logger.Infow("not dispatching agent job since no worker is available",
|
||||||
|
"agentName", desc.AgentName,
|
||||||
|
"jobType", desc.JobType,
|
||||||
|
"room", desc.Room.Name,
|
||||||
|
"roomID", desc.Room.Sid)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +187,12 @@ func (c *agentClient) getDispatcher(agName string, jobType livekit.JobType) *ser
|
|||||||
}
|
}
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
|
if agName == "" {
|
||||||
|
// if no agent name is given, we would need to dispatch backwards compatible mode
|
||||||
|
// which means dispatching to each of the namespaces
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
done := make(chan *serverutils.IncrementalDispatcher[string], 1)
|
done := make(chan *serverutils.IncrementalDispatcher[string], 1)
|
||||||
c.workers.Submit(func() {
|
c.workers.Submit(func() {
|
||||||
agentNames.ForEach(func(ag string) {
|
agentNames.ForEach(func(ag string) {
|
||||||
|
|||||||
+9
-1
@@ -1488,7 +1488,15 @@ func (r *Room) createAgentDispatchesFromRoomAgent() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ag := range r.internal.AgentDispatches {
|
roomDisp := r.internal.AgentDispatches
|
||||||
|
if len(roomDisp) == 0 {
|
||||||
|
// Backward compatibility: by default, start any agent in the empty JobName
|
||||||
|
roomDisp = []*livekit.RoomAgentDispatch{
|
||||||
|
&livekit.RoomAgentDispatch{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ag := range roomDisp {
|
||||||
ad := &livekit.AgentDispatch{
|
ad := &livekit.AgentDispatch{
|
||||||
Id: guid.New(guid.AgentDispatchPrefix),
|
Id: guid.New(guid.AgentDispatchPrefix),
|
||||||
AgentName: ag.AgentName,
|
AgentName: ag.AgentName,
|
||||||
|
|||||||
@@ -106,15 +106,9 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
|
|||||||
internal.TrackEgress = req.Egress.Tracks
|
internal.TrackEgress = req.Egress.Tracks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Agent == nil {
|
if req.Agent != nil {
|
||||||
// Backward compatibility: by default, start any agent in the empty JobName
|
internal.AgentDispatches = req.Agent.Dispatches
|
||||||
req.Agent = &livekit.RoomAgent{
|
|
||||||
Dispatches: []*livekit.RoomAgentDispatch{
|
|
||||||
&livekit.RoomAgentDispatch{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
internal.AgentDispatches = req.Agent.Dispatches
|
|
||||||
if req.MinPlayoutDelay > 0 || req.MaxPlayoutDelay > 0 {
|
if req.MinPlayoutDelay > 0 || req.MaxPlayoutDelay > 0 {
|
||||||
internal.PlayoutDelay = &livekit.PlayoutDelay{
|
internal.PlayoutDelay = &livekit.PlayoutDelay{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user