-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
maxRuns
parameter on workers (#195)
* feat: round robin queueing * feat: configurable max runs per worker * fix: address PR review * docs for max runs and group round robin
- Loading branch information
1 parent
2d625fe
commit 6ea38a9
Showing
46 changed files
with
659 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- name: ListWorkersWithStepCount :many | ||
SELECT | ||
sqlc.embed(workers), | ||
COUNT(runs."id") FILTER (WHERE runs."status" = 'RUNNING') AS "runningStepRuns" | ||
FROM | ||
"Worker" workers | ||
LEFT JOIN | ||
"StepRun" AS runs ON runs."workerId" = workers."id" AND runs."status" = 'RUNNING' | ||
WHERE | ||
workers."tenantId" = @tenantId | ||
AND ( | ||
sqlc.narg('actionId')::text IS NULL OR | ||
workers."id" IN ( | ||
SELECT "_ActionToWorker"."B" | ||
FROM "_ActionToWorker" | ||
INNER JOIN "Action" ON "Action"."id" = "_ActionToWorker"."A" | ||
WHERE "Action"."tenantId" = @tenantId AND "Action"."actionId" = sqlc.narg('actionId')::text | ||
) | ||
) | ||
AND ( | ||
sqlc.narg('lastHeartbeatAfter')::timestamp IS NULL OR | ||
workers."lastHeartbeatAt" > sqlc.narg('lastHeartbeatAfter')::timestamp | ||
) | ||
AND ( | ||
sqlc.narg('assignable')::boolean IS NULL OR | ||
workers."maxRuns" IS NULL OR | ||
(sqlc.narg('assignable')::boolean AND workers."maxRuns" > ( | ||
SELECT COUNT(*) | ||
FROM "StepRun" | ||
WHERE runs."workerId" = workers."id" AND runs."status" = 'RUNNING' | ||
)) | ||
) | ||
GROUP BY | ||
workers."id"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.