1
0
silverbullet/plugos/syscalls/mq.dexie.ts

26 lines
880 B
TypeScript
Raw Normal View History

2023-08-10 16:32:41 +00:00
import { SysCallMapping } from "../system.ts";
import { fullQueueName } from "../lib/mq_util.ts";
2023-08-28 15:12:15 +00:00
import { MessageQueue } from "../lib/mq.ts";
2023-08-10 16:32:41 +00:00
export function mqSyscalls(
2023-08-28 15:12:15 +00:00
mq: MessageQueue,
2023-08-10 16:32:41 +00:00
): SysCallMapping {
return {
"mq.send": (ctx, queue: string, body: any) => {
return mq.send(fullQueueName(ctx.plug.name!, queue), body);
},
"mq.batchSend": (ctx, queue: string, bodies: any[]) => {
return mq.batchSend(fullQueueName(ctx.plug.name!, queue), bodies);
},
"mq.ack": (ctx, queue: string, id: string) => {
return mq.ack(fullQueueName(ctx.plug.name!, queue), id);
},
"mq.batchAck": (ctx, queue: string, ids: string[]) => {
return mq.batchAck(fullQueueName(ctx.plug.name!, queue), ids);
},
2023-08-11 18:37:13 +00:00
"mq.getQueueStats": (ctx, queue: string) => {
return mq.getQueueStats(fullQueueName(ctx.plug.name!, queue));
},
2023-08-10 16:32:41 +00:00
};
}