Files
continuum-backend/src/queue/index.ts
T
octoturge fad0a52690 Initial boilerplate scaffold for continuum-backend
Bun + ElysiaJS control plane: Drizzle/Postgres schema (printers, farms,
print_jobs, pgvector frame_embeddings), R2 presigned URLs, Redis Streams
frame ingestion queue, REST routes, and the /ws/edge/v1 edge-gateway
WebSocket uplink.
2026-08-28 16:13:57 +00:00

34 lines
813 B
TypeScript

import Redis from "ioredis";
export const redis = new Redis(process.env.REDIS_URL ?? "redis://localhost:6379", {
maxRetriesPerRequest: 3,
});
export const CAMERA_FRAMES_STREAM = "stream:camera_frames";
export interface FrameIngestionTask {
farmId: string;
printerId: string;
printJobId: string | null;
r2ObjectKey: string;
capturedAt: string;
}
/** Pushes a frame-ingestion task for continuum-ai-worker to pick up via XREADGROUP. */
export async function enqueueFrameIngestion(task: FrameIngestionTask): Promise<string> {
return redis.xadd(
CAMERA_FRAMES_STREAM,
"*",
"farmId",
task.farmId,
"printerId",
task.printerId,
"printJobId",
task.printJobId ?? "",
"r2ObjectKey",
task.r2ObjectKey,
"capturedAt",
task.capturedAt,
) as Promise<string>;
}