api for agent worker job count (#3068)

* api for agent worker job count

* cleanup

* temp deps

* temp deps

* deps
This commit is contained in:
Paul Wells
2024-10-05 05:13:52 -07:00
committed by GitHub
parent 2491ee7c7c
commit 3261560098
6 changed files with 31 additions and 30 deletions
+3 -2
View File
@@ -38,6 +38,7 @@ import (
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils"
"github.com/livekit/psrpc"
)
@@ -341,7 +342,7 @@ func (h *AgentHandler) JobRequest(ctx context.Context, job *livekit.Job) (*rpc.J
for {
selected, err := h.selectWorkerWeightedByLoad(key, attempted)
if err != nil {
return nil, psrpc.NewError(psrpc.DeadlineExceeded, err)
return nil, psrpc.NewError(psrpc.ResourceExhausted, err)
}
attempted[selected] = struct{}{}
@@ -361,7 +362,7 @@ func (h *AgentHandler) JobRequest(ctx context.Context, job *livekit.Job) (*rpc.J
h.logger.Debugw("assigning job", values...)
state, err := selected.AssignJob(ctx, job)
if err != nil {
if errors.Is(err, agent.ErrWorkerNotAvailable) {
if utils.ErrorIsOneOf(err, agent.ErrWorkerNotAvailable, agent.ErrWorkerClosed) {
continue // Try another worker
}
return nil, err