Files
plainleaf/plug-api/syscalls/mq.ts
T
Zef HemelandGitHub dc2987a3f9 Sync engine rearchitecture (#1516)
* Don't require auth for .ping
* Finally introducing loggers
* Remove file list caching from disk_space_primitives
I don't think this is required anymore with the sync model
* Simplification of space primitives and more tests
* More reliable online status
* Add .zed settings
* Remove selfUpdate argument from `writeFile` no longer used
- Add `sync` config schema and document sync options
- Move sync config handling to client boot logic
- Move BootConfig type to ui_types.ts
- Remove sync env vars from server
- Update documentation for sync and architecture
* Improve sync logic and proxy routing for full sync state
* Add BoxProxy for late-bound client and improve Lua boot
- Add isMobile syscall for editor
* Add concurrency to sync process and log indexing duration
* Better service worker lifecycle management
2025-09-12 14:43:57 +02:00

73 lines
2.0 KiB
TypeScript

import { syscall } from "../syscall.ts";
import type { MQStats } from "../../type/datastore.ts";
/**
* Implements a simple Message Queue system.
* @module
*/
/**
* Sends a message to a queue.
* @param queue the name of the queue to send the message to
* @param body the body of the message to send
*/
export function send(queue: string, body: any): Promise<void> {
return syscall("mq.send", queue, body);
}
/**
* Sends a batch of messages to a queue.
* @param queue the name of the queue
* @param bodies the bodies of the messages to send
*/
export function batchSend(
queue: string,
bodies: any[],
): Promise<void> {
return syscall("mq.batchSend", queue, bodies);
}
/**
* Flushes all messages from a queue.
* @param queue the name of the queue to subscribe to
*/
export function flushQueue(queue: string): Promise<void> {
return syscall("mq.flushQueue", queue);
}
/**
* Acknowledges a message from a queue, in case it needs to be explicitly acknowledged.
* @param queue the name of the queue the message came from
* @param id the id of the message to acknowledge
*/
export function ack(queue: string, id: string): Promise<void> {
return syscall("mq.ack", queue, id);
}
/**
* Acknowledges a batch of messages from a queue, in case they need to be explicitly acknowledged.
* @param queue the name of the queue the messages came from
* @param ids the ids of the messages to acknowledge
*/
export function batchAck(queue: string, ids: string[]): Promise<void> {
return syscall("mq.batchAck", queue, ids);
}
/**
* Retrieves stats on a particular queue.
* @param queue the name of the queue
*/
export function getQueueStats(queue: string): Promise<MQStats> {
return syscall("mq.getQueueStats", queue);
}
/**
* Waits for a queue to become empty.
* @param queue the name of the queue
* @returns a promise that resolves when the queue is empty
*/
export function awaitEmptyQueue(queue: string): Promise<void> {
return syscall("mq.awaitEmptyQueue", queue);
}