Skip to content

Commit

Permalink
change InFlight to Capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-video committed May 4, 2024
1 parent 7aee88b commit 8b5f8d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion worker/container.go
Expand Up @@ -17,7 +17,7 @@ const (

type RunnerContainer struct {
RunnerContainerConfig
inFlight int
Capacity int
Client *ClientWithResponses
}

Expand Down
8 changes: 4 additions & 4 deletions worker/worker.go
Expand Up @@ -265,10 +265,10 @@ func (w *Worker) borrowContainer(ctx context.Context, pipeline, modelID string)
for key, rc := range w.externalContainers {
if rc.Pipeline == pipeline && rc.ModelID == modelID {
// The current implementation of ai-runner containers does not have a queue so only do one request at a time to each container
slog.Info("selecting container to run request", slog.Int("type", int(rc.Type)), slog.Int("inFlight", rc.inFlight), slog.String("url", rc.Endpoint.URL))
if rc.inFlight == 0 {
slog.Info("selecting container to run request", slog.Int("type", int(rc.Type)), slog.Int("capacity", rc.Capacity), slog.String("url", rc.Endpoint.URL))
if rc.Capacity > 0 {
w.mu.Unlock()
w.externalContainers[key].inFlight = 1
w.externalContainers[key].Capacity -= 1
return rc, nil
}
}
Expand All @@ -291,7 +291,7 @@ func (w *Worker) returnContainer(rc *RunnerContainer) {
//free external container for next request
for key, rc := range w.externalContainers {
if w.externalContainers[key].Endpoint.URL == rc.Endpoint.URL {
w.externalContainers[key].inFlight = 0
w.externalContainers[key].Capacity += 1
}
}
}
Expand Down

0 comments on commit 8b5f8d1

Please sign in to comment.