Add message queue flushing to Client: Clean
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user