Add message queue flushing to Client: Clean

This commit is contained in:
Zef Hemel
2026-01-15 08:42:06 +01:00
parent 5a3739adba
commit cf49b9372f
4 changed files with 24 additions and 0 deletions
+7
View File
@@ -356,6 +356,13 @@ export class DataStoreMQ {
await this.ds.batchDelete(ids);
}
/**
* Flushes all queues
*/
flushAllQueues() {
return this.ds.batchDeletePrefix(["mq"]);
}
async getQueueStats(queue?: string): Promise<MQStats> {
const queued = await this.ds.kv.countQuery({
prefix: queue ? [...queuedPrefix, queue] : queuedPrefix,
+3
View File
@@ -39,6 +39,9 @@ export function mqSyscalls(
"mq.flushQueue": (_ctx, queue: string) => {
return mq.flushQueue(queue);
},
"mq.flushAllQueues": () => {
return mq.flushAllQueues();
},
"mq.getQueueStats": (_ctx, queue: string) => {
return mq.getQueueStats(queue);
},
+7
View File
@@ -36,6 +36,13 @@ export function flushQueue(queue: string): Promise<void> {
return syscall("mq.flushQueue", queue);
}
/**
* Flushes all messages from all queues.
*/
export function flushAllQueues(): Promise<void> {
return syscall("mq.flushAllQueues");
}
/**
* 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
+7
View File
@@ -1,6 +1,7 @@
import {
editor,
markdown,
mq,
system,
} from "@silverbulletmd/silverbullet/syscalls";
@@ -30,7 +31,13 @@ export async function wipeAndLogoutCommand() {
await system.wipeClient(true);
}
/**
* Does the following:
* - Flushes all message queues
* - Cleans IndexedDB databases not connected to the current space
*/
export async function cleanClientCommand() {
await mq.flushAllQueues();
if (await system.cleanDatabases()) {
await editor.alert("Successfullly cleaned unnecessary client databases.");
} else {