Spaces:
Runtime error
Runtime error
Download src/lib/queue/producer.ts from damndeepesh-dev/RippleWorkers: direct link, hf CLI and curl.
- Browser
- Download file 825 Bytes
-
https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/lib/queue/producer.ts
- Command line
-
hf download hf://spaces/damndeepesh-dev/RippleWorkers/src/lib/queue/producer.ts
-
curl -L -o producer.ts https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/lib/queue/producer.ts
825 Bytes
| import { getChannel } from "@/lib/lavinmq"; | |
| export const QUEUE_NAME = "publish_jobs"; | |
| export async function enqueuePublishJob(postId: string) { | |
| const channel = await getChannel(); | |
| // assertQueue checks if the queue exists, if not it creates it. | |
| // durable: true means the queue survives broker restarts | |
| await channel.assertQueue(QUEUE_NAME, { durable: true }); | |
| const message = JSON.stringify({ postId }); | |
| // persistent: true means messages are saved to disk | |
| const sent = channel.sendToQueue(QUEUE_NAME, Buffer.from(message), { | |
| persistent: true | |
| }); | |
| if (sent) { | |
| console.log(`[LavinMQ] Enqueued job for post ${postId}`); | |
| } else { | |
| console.error(`[LavinMQ] Failed to enqueue job for post ${postId}`); | |
| throw new Error("Failed to enqueue job"); | |
| } | |
| } | |