Work on client modes

This commit is contained in:
Zef Hemel
2023-08-29 21:17:29 +02:00
parent 5ff1a8bae3
commit 9a005f26b5
54 changed files with 594 additions and 302 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import { sleep } from "../../common/async_util.ts";
import { sleep } from "$sb/lib/async.ts";
import { DenoKvMQ } from "./mq.deno_kv.ts";
Deno.test("Deno MQ", async () => {
+10 -4
View File
@@ -41,14 +41,20 @@ export class DenoKvMQ implements MessageQueue {
}
async batchSend(queue: string, bodies: any[]): Promise<void> {
const results = await Promise.all(
bodies.map((body) => this.kv.enqueue([queue, body])),
);
for (const result of results) {
for (const body of bodies) {
const result = await this.kv.enqueue([queue, body]);
if (!result.ok) {
throw result;
}
}
// const results = await Promise.all(
// bodies.map((body) => this.kv.enqueue([queue, body])),
// );
// for (const result of results) {
// if (!result.ok) {
// throw result;
// }
// }
}
async send(queue: string, body: any): Promise<void> {
const result = await this.kv.enqueue([queue, body]);
+1 -1
View File
@@ -1,7 +1,7 @@
import { IDBKeyRange, indexedDB } from "https://esm.sh/fake-indexeddb@4.0.2";
import { DexieMQ } from "./mq.dexie.ts";
import { assertEquals } from "../../test_deps.ts";
import { sleep } from "../../common/async_util.ts";
import { sleep } from "$sb/lib/async.ts";
Deno.test("Dexie MQ", async () => {
const mq = new DexieMQ("test", indexedDB, IDBKeyRange);