silverbullet/lib/data/mq.ts

21 lines
594 B
TypeScript
Raw Normal View History

2024-07-30 23:33:33 +08:00
import type {
2024-02-29 22:23:05 +08:00
MQMessage,
MQStats,
MQSubscribeOptions,
} from "../../plug-api/types.ts";
2023-08-28 23:12:15 +08:00
export interface MessageQueue {
batchSend(queue: string, bodies: any[]): Promise<void>;
send(queue: string, body: any): Promise<void>;
subscribe(
queue: string,
options: MQSubscribeOptions,
callback: (messages: MQMessage[]) => Promise<void> | void,
): () => void;
ack(queue: string, id: string): Promise<void>;
batchAck(queue: string, ids: string[]): Promise<void>;
getQueueStats(queue: string): Promise<MQStats>;
getAllQueueStats(): Promise<Record<string, MQStats>>;
}