Skip to content

Implement AgentDispatch service - #2919

Merged
biglittlebigben merged 14 commits into
masterfrom
benjamin/agent_dispatch_twirp
Aug 8, 2024
Merged

biglittlebigben merged 14 commits into
masterfrom
benjamin/agent_dispatch_twirp

Conversation

@biglittlebigben

Copy link
Copy Markdown
Contributor

This allows listing, adding and deleting agent dispatches on an existing room. Requests go to a new AgentDispatchService, which sends them over RPC to the rtc.Room via the RoomManager. The rtc.Room then does agent job management using RPCs to the agent service.

@biglittlebigben
biglittlebigben requested a review from paulwe August 8, 2024 18:16
Comment thread pkg/rtc/room.go Outdated

// This provides utilities attached the agent dispatch to ensure that all pending jobs are created
// before terminating jobs attached to an agent dispatch. This avoids a race that could cause some pending jobs
// to not be terninated when a dispatch is deleted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminated

Comment thread pkg/rtc/room.go Outdated
j.lock.Unlock()
}

func (j *agentJob) waitForParticipantLeaving(mu *sync.RWMutex) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is mu for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A leftover from a refactor... I removed it.

Comment thread pkg/rtc/room.go
@@ -199,7 +288,7 @@ func NewRoom(

r.createAgentDispatchesFromRoomAgent()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be async?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want createAgentDispatchesFromRoomAgent to have run by the time NewRoom returns, as its output is needed by the agents lifecycle RPCs. It does very little though (the only potentially blocking call is to storage).

launchRoomAgents could be run in its own goroutine, but it already instantiate goroutines internally do do actual work

Comment thread pkg/service/agent_dispatch_service.go Outdated
return nil, twirpAuthError(err)
}

return ag.agentDispatchClient.CreateDispatch(ctx, rpc.RoomTopic(req.Room), req)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need an rpc.TopicFormatter in this service (see RoomService) to support cloud topics

Comment thread pkg/service/roommanager.go Outdated
return nil, ErrRoomNotFound
}

room.Logger.Debugw("room ListDispatch", "dispatchID", req.DispatchId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server rpc logging should already give us these

Comment thread pkg/agent/worker.go Outdated
err := w.updateJobStatus(update)

if err != nil {
w.logger.Infow("received job update for unknown job", "jobId", update.JobId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jobID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants