Partial support for agent dispatch management (#2872)

- Store agent dispaches independently of room agents on rtc.Room
- Serialize agent dispatches in rtc.Room
- Support for agent dispatch and job serialization in redis

The agent Job object references denormalized Room and ParticipantInfo object. When storing Jobs, this sets the Room to nil, and only stores the Participant identity field. When read back, these fields need to be set to their current value.
This commit is contained in:
Benjamin Pracht
2024-07-18 13:36:43 -07:00
committed by GitHub
parent 95f4b304ef
commit a877ba2352
17 changed files with 887 additions and 81 deletions
+1 -19
View File
@@ -517,31 +517,13 @@ func (s *RTCService) startConnection(
timeout time.Duration,
) (connectionResult, *livekit.SignalResponse, error) {
var cr connectionResult
var created bool
var err error
cr.Room, created, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName), ConfigName: GetRoomConfiguration(ctx)})
cr.Room, _, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName), ConfigName: GetRoomConfiguration(ctx)})
if err != nil {
return cr, nil, err
}
if created && s.agentClient != nil {
// TODO Have CreateRoom return the RoomInternal object?
_, internal, err := s.store.LoadRoom(ctx, livekit.RoomName(roomName), true)
if err != nil {
return connectionResult{}, nil, err
}
for _, ag := range internal.AgentDispatches {
go s.agentClient.LaunchJob(ctx, &agent.JobRequest{
JobType: livekit.JobType_JT_ROOM,
Room: cr.Room,
Metadata: ag.Metadata,
AgentName: ag.AgentName,
})
}
}
// this needs to be started first *before* using router functions on this node
cr.StartParticipantSignalResults, err = s.router.StartParticipantSignal(ctx, roomName, pi)
if err != nil {