Add task queue with dedup and concurrency control
Publish Image / publish (push) Successful in 54s

- Tasks keyed by {taskType}-{repo}-{issue} for deduplication
- Duplicate requests (pending or running) are dropped
- Configurable concurrency via QUEUE_CONCURRENCY env (default 2)
- Workspace names now {taskType}-{repo}-{issue} for observability
- GET /queue endpoint shows pending/running tasks
- All handlers route through the queue instead of calling Coder directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel Samson
2026-04-12 13:30:27 +01:00
co-authored by Claude Opus 4.6
parent 6062d1b518
commit f23fb4e2e0
10 changed files with 168 additions and 107 deletions
+7 -15
View File
@@ -1,7 +1,6 @@
import type { Context } from "hono";
import type { IssueEvent, TaskRequest } from "../types.js";
import type { CoderClient } from "../services/coder.js";
import type { GiteaClient } from "../services/gitea.js";
import type { TaskQueue } from "../queue.js";
import type { Config } from "../config.js";
const LABEL_TO_TASK: Record<string, string> = {
@@ -19,7 +18,7 @@ const REVIEW_TASKS = new Set(["test"]);
*
* Replaces: issue-stage-transition.json
*/
export function issueLabel(config: Config, coder: CoderClient, gitea: GiteaClient) {
export function issueLabel(config: Config, queue: TaskQueue) {
return async (c: Context) => {
const event = await c.req.json<IssueEvent>();
@@ -55,18 +54,11 @@ export function issueLabel(config: Config, coder: CoderClient, gitea: GiteaClien
giteaToken,
};
console.log(`[issue-label] #${task.issueNumber} → ${taskType}`);
const queued = queue.enqueue(task, {
useReviewAccount: false,
body: `🤖 SDLC stage transition: **${taskType}** — workspace queued.`,
});
const workspace = await coder.createWorkspace(task);
console.log(`[issue-label] workspace created: ${workspace.name}`);
await gitea.commentOnIssue(
org,
repo,
event.issue.number,
`🤖 SDLC stage transition: **${taskType}** — workspace created.`,
);
return c.json({ ok: true, workspace: workspace.name });
return c.json({ ok: true, queued });
};
}