| 1234567891011121314151617181920212223242526 |
- const TASK_QUEUE = 'runforge_task_queue'
- /**
- * 声明乐跑任务主队列(无 RabbitMQ 插件)
- */
- async function assertRunforgeTaskIngress(channel, logger) {
- await channel.assertQueue(TASK_QUEUE, { durable: true })
- return { mode: 'direct', queue: TASK_QUEUE }
- }
- /**
- * 投递乐跑任务 JSON 消息体(与 Worker 消费格式一致)
- */
- function publishRunforgeTask(channel, messageObject) {
- const body = Buffer.from(JSON.stringify(messageObject))
- channel.sendToQueue(TASK_QUEUE, body, {
- persistent: true,
- contentType: 'application/json'
- })
- }
- module.exports = {
- TASK_QUEUE,
- assertRunforgeTaskIngress,
- publishRunforgeTask
- }
|