Publish Image / publish (push) Successful in 36s
Replace the volatile in-memory Map/Set queue with BullMQ backed by Redis for persistence across restarts, automatic retry with exponential backoff, and non-blocking workspace cleanup. - Two queues: workspace-create (concurrency-limited) and workspace-cleanup (with polling instead of sleep-based stop→delete) - Active workspaces tracked in Redis hash for dedup across restarts - Stale sweep every 10 minutes catches orphaned workspaces - Graceful shutdown on SIGTERM/SIGINT - Replace node-cron with BullMQ repeatable jobs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import type { Context } from "hono";
|
|
import type { IssueEvent, TaskRequest } from "../types.js";
|
|
import type { TaskQueue } from "../queue.js";
|
|
import type { Config } from "../config.js";
|
|
|
|
/**
|
|
* Issue opened → route to analyst or fix-bug.
|
|
*
|
|
* Replaces: gitea-issue-triage.json
|
|
*/
|
|
export function issueTriage(config: Config, queue: TaskQueue) {
|
|
return async (c: Context) => {
|
|
const event = await c.req.json<IssueEvent>();
|
|
|
|
if (event.action !== "opened") {
|
|
return c.text("ignored: not an open event", 200);
|
|
}
|
|
|
|
const labels = event.issue.labels.map((l) => l.name);
|
|
const [org, repo] = event.repository.full_name.split("/");
|
|
|
|
const isBug = labels.includes("bug");
|
|
const taskType = isBug ? "fix-bug" : "analyse";
|
|
|
|
const task: TaskRequest = {
|
|
taskType,
|
|
issueNumber: event.issue.number,
|
|
giteaOrg: org,
|
|
giteaRepo: repo,
|
|
repoCloneUrl: event.repository.clone_url,
|
|
giteaToken: config.giteaDevToken,
|
|
};
|
|
|
|
const queued = await queue.enqueue(task, {
|
|
useReviewAccount: false,
|
|
body: `🤖 Issue received. Starting **${taskType}** stage.`,
|
|
});
|
|
|
|
return c.json({ ok: true, queued });
|
|
};
|
|
}
|