| 123456789101112131415161718192021222324252627 |
- const { mq } = require('./mqPrefix')
- const TASK_QUEUE = mq('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
- }
|