@fedify/fedify 2.5.0-dev.2664 → 2.5.0-dev.2710
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/{context-xrqq4Hrq.d.ts → context-CuLvR1Os.d.ts} +2 -2
- package/dist/{context-C1NqcIct.d.cts → context-apq0IBg2.d.cts} +2 -2
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/{federation-FbwcnRHg.cjs → federation-JvzYDx0P.cjs} +5 -5
- package/dist/{http-DbvOPsFZ.cjs → http-BG5cDmTS.cjs} +1 -1
- package/dist/{http-CWn0K5jD.js → http-MUf125Jc.js} +1 -1
- package/dist/{key-dwwAg5bA.d.ts → key-BZw-YiK5.d.ts} +2 -2
- package/dist/{key-DlHT4R6k.d.cts → key-D5fbQkKM.d.cts} +2 -2
- package/dist/{kv-cache-B-fOrhb-.cjs → kv-cache-A2po7h0_.cjs} +1 -1
- package/dist/{kv-cache-BC837EqC.js → kv-cache-CbWc1BZA.js} +1 -1
- package/dist/{ld-CWVpo_NM.d.cts → ld-DEi9ERHf.d.cts} +1 -1
- package/dist/{ld-o4LnhCYY.d.ts → ld-DlC78ioJ.d.ts} +1 -1
- package/dist/{middleware-n2UrG62B.js → middleware-DzzdJ7Wz.js} +5 -5
- package/dist/{mod-D22ZsiKi.d.ts → mod-BJRtsw7l.d.ts} +1 -1
- package/dist/{mod-C1nT74IG.d.cts → mod-BamwZjJx.d.cts} +1 -1
- package/dist/{mod-DO0epJGH.d.ts → mod-BkTi19dI.d.ts} +1 -1
- package/dist/{mod-CQC9xlLZ.d.ts → mod-CMtF0VVy.d.ts} +1 -1
- package/dist/{mod-YvA4Rk8J.d.cts → mod-D2Z9MiCm.d.cts} +1 -1
- package/dist/{mod-TwiQgEf3.d.cts → mod-DB2NOzQF.d.cts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +6 -6
- package/dist/mod.d.ts +6 -6
- package/dist/mod.js +4 -4
- package/dist/{portable-collection-DQhIkX5a.js → portable-collection-CAer9RWN.js} +1 -1
- package/dist/{portable-collection-DseoiPPj.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +22 -9
- package/skills/fedify/SKILL.md +10 -0
- package/dist/accept-CPVqki78.mjs +0 -145
- package/dist/activity-listener-CELFAodc.mjs +0 -44
- package/dist/assert-D1Eafmd_.mjs +0 -23
- package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
- package/dist/assert_exists-cffSpJ7X.mjs +0 -28
- package/dist/assert_false-CPdRnc3E.mjs +0 -23
- package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
- package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
- package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
- package/dist/assert_rejects-CTptdYck.mjs +0 -39
- package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
- package/dist/assert_throws-BYITOvPO.mjs +0 -74
- package/dist/assertion_error-B-cx0fFA.mjs +0 -31
- package/dist/audience-CHQ-FlLD.mjs +0 -95
- package/dist/builder-CGJ-NXcZ.mjs +0 -911
- package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
- package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
- package/dist/client-5SIFzW3q.mjs +0 -441
- package/dist/codec-C6rTrpIp.mjs +0 -147
- package/dist/collection-CnnP1UAv.mjs +0 -44
- package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
- package/dist/compat/outgoing-jsonld.test.mjs +0 -257
- package/dist/compat/public-audience.test.d.mts +0 -2
- package/dist/compat/public-audience.test.mjs +0 -187
- package/dist/compat/secured-document.test.d.mts +0 -2
- package/dist/compat/secured-document.test.mjs +0 -58
- package/dist/compat/transformers.test.d.mts +0 -2
- package/dist/compat/transformers.test.mjs +0 -62
- package/dist/compound-proof-CnzwOddk.mjs +0 -1019
- package/dist/context-LgGFFSz7.mjs +0 -146
- package/dist/deno-eoFpPk7W.mjs +0 -8
- package/dist/dist-_geWsuaI.mjs +0 -189
- package/dist/docloader-DwkipyL1.mjs +0 -136
- package/dist/esm-BHXXx4Wx.mjs +0 -1233
- package/dist/exporter-DVG68ozH.mjs +0 -263
- package/dist/federation/audience.test.d.mts +0 -2
- package/dist/federation/audience.test.mjs +0 -130
- package/dist/federation/builder.test.d.mts +0 -2
- package/dist/federation/builder.test.mjs +0 -396
- package/dist/federation/circuit-breaker.test.d.mts +0 -2
- package/dist/federation/circuit-breaker.test.mjs +0 -1277
- package/dist/federation/collection.test.d.mts +0 -2
- package/dist/federation/collection.test.mjs +0 -21
- package/dist/federation/compound-fanout.test.d.mts +0 -2
- package/dist/federation/compound-fanout.test.mjs +0 -231
- package/dist/federation/handler-compound-proof.test.d.mts +0 -2
- package/dist/federation/handler-compound-proof.test.mjs +0 -384
- package/dist/federation/handler.test.d.mts +0 -2
- package/dist/federation/handler.test.mjs +0 -5445
- package/dist/federation/hashlink-media.test.d.mts +0 -2
- package/dist/federation/hashlink-media.test.mjs +0 -422
- package/dist/federation/idempotency.test.d.mts +0 -2
- package/dist/federation/idempotency.test.mjs +0 -207
- package/dist/federation/inbox-actorless.test.d.mts +0 -2
- package/dist/federation/inbox-actorless.test.mjs +0 -522
- package/dist/federation/inbox-authentication.test.d.mts +0 -2
- package/dist/federation/inbox-authentication.test.mjs +0 -220
- package/dist/federation/inbox-report.test.d.mts +0 -2
- package/dist/federation/inbox-report.test.mjs +0 -719
- package/dist/federation/inbox-view.test.d.mts +0 -2
- package/dist/federation/inbox-view.test.mjs +0 -369
- package/dist/federation/inbox.test.d.mts +0 -2
- package/dist/federation/inbox.test.mjs +0 -139
- package/dist/federation/keycache.test.d.mts +0 -2
- package/dist/federation/keycache.test.mjs +0 -337
- package/dist/federation/kv.test.d.mts +0 -2
- package/dist/federation/kv.test.mjs +0 -88
- package/dist/federation/metrics.test.d.mts +0 -2
- package/dist/federation/metrics.test.mjs +0 -634
- package/dist/federation/middleware.test.d.mts +0 -2
- package/dist/federation/middleware.test.mjs +0 -9314
- package/dist/federation/mq.test.d.mts +0 -2
- package/dist/federation/mq.test.mjs +0 -591
- package/dist/federation/negotiation.test.d.mts +0 -2
- package/dist/federation/negotiation.test.mjs +0 -18
- package/dist/federation/outbound-body.test.d.mts +0 -2
- package/dist/federation/outbound-body.test.mjs +0 -149
- package/dist/federation/outbound-capture.test.d.mts +0 -2
- package/dist/federation/outbound-capture.test.mjs +0 -394
- package/dist/federation/outbound-dispatch.test.d.mts +0 -2
- package/dist/federation/outbound-dispatch.test.mjs +0 -368
- package/dist/federation/outbound-document.test.d.mts +0 -2
- package/dist/federation/outbound-document.test.mjs +0 -171
- package/dist/federation/outbound-provenance.test.d.mts +0 -2
- package/dist/federation/outbound-provenance.test.mjs +0 -543
- package/dist/federation/outbound-report.test.d.mts +0 -2
- package/dist/federation/outbound-report.test.mjs +0 -5475
- package/dist/federation/outbound-workers.test.d.mts +0 -2
- package/dist/federation/outbound-workers.test.mjs +0 -64
- package/dist/federation/outbound-workflow.test.d.mts +0 -2
- package/dist/federation/outbound-workflow.test.mjs +0 -154
- package/dist/federation/outgoing-proof.test.d.mts +0 -2
- package/dist/federation/outgoing-proof.test.mjs +0 -933
- package/dist/federation/portable-actor.test.d.mts +0 -2
- package/dist/federation/portable-actor.test.mjs +0 -496
- package/dist/federation/portable-chain.test.d.mts +0 -2
- package/dist/federation/portable-chain.test.mjs +0 -370
- package/dist/federation/portable-collection.test.d.mts +0 -2
- package/dist/federation/portable-collection.test.mjs +0 -832
- package/dist/federation/portable-delivery.test.d.mts +0 -2
- package/dist/federation/portable-delivery.test.mjs +0 -845
- package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
- package/dist/federation/portable-gateway-keys.test.mjs +0 -692
- package/dist/federation/portable-inbox.test.d.mts +0 -2
- package/dist/federation/portable-inbox.test.mjs +0 -1960
- package/dist/federation/portable-parse-uri.test.d.mts +0 -2
- package/dist/federation/portable-parse-uri.test.mjs +0 -348
- package/dist/federation/portable-route-activity.test.d.mts +0 -2
- package/dist/federation/portable-route-activity.test.mjs +0 -259
- package/dist/federation/portable.test.d.mts +0 -2
- package/dist/federation/portable.test.mjs +0 -1072
- package/dist/federation/retry.test.d.mts +0 -2
- package/dist/federation/retry.test.mjs +0 -42
- package/dist/federation/router.test.d.mts +0 -2
- package/dist/federation/router.test.mjs +0 -123
- package/dist/federation/send.test.d.mts +0 -2
- package/dist/federation/send.test.mjs +0 -1421
- package/dist/federation/tasks/codec.test.d.mts +0 -2
- package/dist/federation/tasks/codec.test.mjs +0 -302
- package/dist/federation/tasks/enqueue.test.d.mts +0 -2
- package/dist/federation/tasks/enqueue.test.mjs +0 -1095
- package/dist/federation/tasks/tasks.test.d.mts +0 -2
- package/dist/federation/tasks/tasks.test.mjs +0 -1229
- package/dist/federation/temporal.test.d.mts +0 -2
- package/dist/federation/temporal.test.mjs +0 -71
- package/dist/federation/webfinger.test.d.mts +0 -2
- package/dist/federation/webfinger.test.mjs +0 -944
- package/dist/http-l1zKGCll.mjs +0 -1449
- package/dist/inbox-CWX3EBTO.mjs +0 -399
- package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
- package/dist/inbox-view-DkPCF71K.mjs +0 -385
- package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
- package/dist/keycache-N2opu4-3.mjs +0 -221
- package/dist/keys-DIJNHW-Y.mjs +0 -120
- package/dist/kv-DBRWVx3Q.mjs +0 -104
- package/dist/kv-DCHkaJ9-.mjs +0 -92
- package/dist/kv-cache-8eJh4Xum.mjs +0 -121
- package/dist/ld-Cdt8qD-r.mjs +0 -1752
- package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
- package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
- package/dist/metrics-BnfvSPj9.mjs +0 -818
- package/dist/middleware-CwnXJze2.mjs +0 -5
- package/dist/middleware-D_W_LdJN.mjs +0 -9971
- package/dist/mq-eF96QxUT.mjs +0 -288
- package/dist/negotiation-BAKO9nih.mjs +0 -96
- package/dist/nodeinfo/client.test.d.mts +0 -2
- package/dist/nodeinfo/client.test.mjs +0 -1364
- package/dist/nodeinfo/handler.test.d.mts +0 -2
- package/dist/nodeinfo/handler.test.mjs +0 -94
- package/dist/nodeinfo/types.test.d.mts +0 -2
- package/dist/nodeinfo/types.test.mjs +0 -192
- package/dist/otel/exporter.test.d.mts +0 -2
- package/dist/otel/exporter.test.mjs +0 -887
- package/dist/outbound-body-CckPA5gc.mjs +0 -83
- package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
- package/dist/outbound-document-BMgwLXTY.mjs +0 -179
- package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
- package/dist/owner-DukEQnv3.mjs +0 -267
- package/dist/portable-collection-OHaqa11n.mjs +0 -418
- package/dist/portable-key-BkOLJxVz.mjs +0 -549
- package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
- package/dist/proof-Y7omSVvc.mjs +0 -1420
- package/dist/public-audience--klBIOk1.mjs +0 -197
- package/dist/retry-zX5xw5e0.mjs +0 -34
- package/dist/router-u5O5KCQr.mjs +0 -156
- package/dist/secured-document-CxzZZ9nL.mjs +0 -35
- package/dist/send-ccQynabr.mjs +0 -710
- package/dist/sig/accept.test.d.mts +0 -2
- package/dist/sig/accept.test.mjs +0 -416
- package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
- package/dist/sig/compound-proof-discovery.test.mjs +0 -331
- package/dist/sig/compound-proof-producer.test.d.mts +0 -2
- package/dist/sig/compound-proof-producer.test.mjs +0 -107
- package/dist/sig/compound-proof-verification.test.d.mts +0 -2
- package/dist/sig/compound-proof-verification.test.mjs +0 -1017
- package/dist/sig/compound-proof.test.d.mts +0 -2
- package/dist/sig/compound-proof.test.mjs +0 -411
- package/dist/sig/http.test.d.mts +0 -2
- package/dist/sig/http.test.mjs +0 -3328
- package/dist/sig/key-owner-evidence.test.d.mts +0 -2
- package/dist/sig/key-owner-evidence.test.mjs +0 -100
- package/dist/sig/key.test.d.mts +0 -2
- package/dist/sig/key.test.mjs +0 -1250
- package/dist/sig/ld.test.d.mts +0 -2
- package/dist/sig/ld.test.mjs +0 -1044
- package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
- package/dist/sig/mitra-receive-interop.test.mjs +0 -260
- package/dist/sig/mitra-send-interop.test.d.mts +0 -2
- package/dist/sig/mitra-send-interop.test.mjs +0 -461
- package/dist/sig/owner.test.d.mts +0 -2
- package/dist/sig/owner.test.mjs +0 -202
- package/dist/sig/portable-collection.test.d.mts +0 -2
- package/dist/sig/portable-collection.test.mjs +0 -697
- package/dist/sig/portable-interop.test.d.mts +0 -2
- package/dist/sig/portable-interop.test.mjs +0 -156
- package/dist/sig/portable-key-id.test.d.mts +0 -2
- package/dist/sig/portable-key-id.test.mjs +0 -67
- package/dist/sig/portable-key.test.d.mts +0 -2
- package/dist/sig/portable-key.test.mjs +0 -1438
- package/dist/sig/proof.test.d.mts +0 -2
- package/dist/sig/proof.test.mjs +0 -2638
- package/dist/sig/tootik-request-interop.test.d.mts +0 -2
- package/dist/sig/tootik-request-interop.test.mjs +0 -190
- package/dist/sig/tootik-send-interop.test.d.mts +0 -2
- package/dist/sig/tootik-send-interop.test.mjs +0 -331
- package/dist/sig/verification.test.d.mts +0 -2
- package/dist/sig/verification.test.mjs +0 -310
- package/dist/std__assert-DvMDRPes.mjs +0 -8
- package/dist/tasks-BCUmQbbz.mjs +0 -77
- package/dist/temporal-f_K4lAVR.mjs +0 -95
- package/dist/testing/context.test.d.mts +0 -2
- package/dist/testing/context.test.mjs +0 -19
- package/dist/testing/kv.test.d.mts +0 -2
- package/dist/testing/kv.test.mjs +0 -101
- package/dist/testing/mod.d.mts +0 -6099
- package/dist/testing/mod.mjs +0 -9
- package/dist/testing-vrnD5Uaa.mjs +0 -8
- package/dist/types-DE_LV1JB.mjs +0 -46
- package/dist/utils/docloader.test.d.mts +0 -2
- package/dist/utils/docloader.test.mjs +0 -1076
- package/dist/utils/kv-cache.test.d.mts +0 -2
- package/dist/utils/kv-cache.test.mjs +0 -261
- package/dist/verification-C3954hQh.mjs +0 -5
- package/dist/verification-Dpfcw8ml.mjs +0 -105
- package/dist/vocab/cjs.test.d.mts +0 -2
- package/dist/vocab/cjs.test.mjs +0 -27
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
import { Temporal } from "temporal-polyfill";
|
|
2
|
-
import "urlpattern-polyfill";
|
|
3
|
-
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
|
-
import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
|
|
6
|
-
import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BlafOF4-.mjs";
|
|
7
|
-
import "../std__assert-DvMDRPes.mjs";
|
|
8
|
-
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
9
|
-
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
10
|
-
import { r as estimateQueuedMessageSize } from "../inbox-CWX3EBTO.mjs";
|
|
11
|
-
import { n as ParallelMessageQueue, t as InProcessMessageQueue } from "../mq-eF96QxUT.mjs";
|
|
12
|
-
import { delay } from "es-toolkit";
|
|
13
|
-
import { test } from "@fedify/fixture";
|
|
14
|
-
//#region src/federation/mq.test.ts
|
|
15
|
-
async function disposeMessageQueue(mq) {
|
|
16
|
-
if (Symbol.asyncDispose in mq) {
|
|
17
|
-
const dispose = mq[Symbol.asyncDispose];
|
|
18
|
-
if (typeof dispose === "function") {
|
|
19
|
-
await dispose.call(mq);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (Symbol.dispose in mq) {
|
|
24
|
-
const dispose = mq[Symbol.dispose];
|
|
25
|
-
if (typeof dispose === "function") dispose.call(mq);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
test("InProcessMessageQueue", async (t) => {
|
|
29
|
-
const mq = new InProcessMessageQueue();
|
|
30
|
-
await t.step("nativeRetrial property", () => {
|
|
31
|
-
assertFalse(mq.nativeRetrial);
|
|
32
|
-
});
|
|
33
|
-
await t.step("nativeDeduplication property", () => {
|
|
34
|
-
assertFalse(mq.nativeDeduplication);
|
|
35
|
-
});
|
|
36
|
-
await t.step("getDepth() [empty]", async () => {
|
|
37
|
-
assertEquals(await mq.getDepth(), {
|
|
38
|
-
queued: 0,
|
|
39
|
-
ready: 0,
|
|
40
|
-
delayed: 0
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
const messages = [];
|
|
44
|
-
const controller = new AbortController();
|
|
45
|
-
const listening = mq.listen((message) => {
|
|
46
|
-
messages.push(message);
|
|
47
|
-
}, controller);
|
|
48
|
-
try {
|
|
49
|
-
await t.step("enqueue()", async () => {
|
|
50
|
-
await mq.enqueue("Hello, world!");
|
|
51
|
-
});
|
|
52
|
-
await waitFor(() => messages.length > 0, 15e3);
|
|
53
|
-
await t.step("listen()", () => {
|
|
54
|
-
assertEquals(messages, ["Hello, world!"]);
|
|
55
|
-
});
|
|
56
|
-
await t.step("enqueue() with delay", async () => {
|
|
57
|
-
const { timers, enqueued } = captureTimers(() => mq.enqueue("Delayed message", { delay: Temporal.Duration.from({ seconds: 3 }) }));
|
|
58
|
-
await enqueued;
|
|
59
|
-
assertEquals(timers.length, 1);
|
|
60
|
-
assertEquals(timers[0].delay, 3e3);
|
|
61
|
-
await mq.enqueue("Single delay marker");
|
|
62
|
-
await waitFor(() => messages.includes("Single delay marker"), 15e3);
|
|
63
|
-
assertEquals(messages, ["Hello, world!", "Single delay marker"]);
|
|
64
|
-
timers[0].callback();
|
|
65
|
-
});
|
|
66
|
-
await waitFor(() => messages.length >= 3, 15e3);
|
|
67
|
-
await t.step("listen() with delay", () => {
|
|
68
|
-
assertEquals(messages, [
|
|
69
|
-
"Hello, world!",
|
|
70
|
-
"Single delay marker",
|
|
71
|
-
"Delayed message"
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
while (messages.length > 0) messages.pop();
|
|
75
|
-
await t.step("enqueueMany()", async () => {
|
|
76
|
-
const testMessages = Array.from({ length: 5 }, (_, i) => `Batch message ${i}!`);
|
|
77
|
-
await mq.enqueueMany(testMessages);
|
|
78
|
-
});
|
|
79
|
-
await waitFor(() => messages.length >= 5, 15e3);
|
|
80
|
-
await t.step("listen() [multiple]", () => {
|
|
81
|
-
assertEquals(messages.length, 5);
|
|
82
|
-
for (let i = 0; i < 5; i++) assertEquals(messages[i], `Batch message ${i}!`);
|
|
83
|
-
});
|
|
84
|
-
while (messages.length > 0) messages.pop();
|
|
85
|
-
await t.step("enqueueMany() with delay", async () => {
|
|
86
|
-
const testMessages = Array.from({ length: 3 }, (_, i) => `Delayed batch ${i}!`);
|
|
87
|
-
const { timers, enqueued } = captureTimers(() => mq.enqueueMany(testMessages, { delay: Temporal.Duration.from({ seconds: 2 }) }));
|
|
88
|
-
await enqueued;
|
|
89
|
-
assertEquals(timers.length, 1);
|
|
90
|
-
assertEquals(timers[0].delay, 2e3);
|
|
91
|
-
await mq.enqueue("Batch delay marker");
|
|
92
|
-
await waitFor(() => messages.includes("Batch delay marker"), 15e3);
|
|
93
|
-
assertEquals(messages, ["Batch delay marker"]);
|
|
94
|
-
timers[0].callback();
|
|
95
|
-
});
|
|
96
|
-
await waitFor(() => messages.length >= 4, 15e3);
|
|
97
|
-
await t.step("listen() [delayed multiple]", () => {
|
|
98
|
-
assertEquals(messages.length, 4);
|
|
99
|
-
assertEquals(messages[0], "Batch delay marker");
|
|
100
|
-
for (let i = 0; i < 3; i++) assertEquals(messages[i + 1], `Delayed batch ${i}!`);
|
|
101
|
-
});
|
|
102
|
-
} finally {
|
|
103
|
-
controller.abort();
|
|
104
|
-
await listening;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
function captureTimers(enqueue) {
|
|
108
|
-
const timers = [];
|
|
109
|
-
const original = globalThis.setTimeout;
|
|
110
|
-
globalThis.setTimeout = ((callback, delay) => {
|
|
111
|
-
timers.push({
|
|
112
|
-
callback,
|
|
113
|
-
delay
|
|
114
|
-
});
|
|
115
|
-
return 0;
|
|
116
|
-
});
|
|
117
|
-
try {
|
|
118
|
-
return {
|
|
119
|
-
timers,
|
|
120
|
-
enqueued: enqueue()
|
|
121
|
-
};
|
|
122
|
-
} finally {
|
|
123
|
-
globalThis.setTimeout = original;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
test("InProcessMessageQueue real delay", async (t) => {
|
|
127
|
-
for (const batch of [false, true]) await t.step(batch ? "enqueueMany()" : "enqueue()", async () => {
|
|
128
|
-
const mq = new InProcessMessageQueue();
|
|
129
|
-
const messages = [];
|
|
130
|
-
const controller = new AbortController();
|
|
131
|
-
const listening = mq.listen((message) => {
|
|
132
|
-
messages.push(message);
|
|
133
|
-
}, controller);
|
|
134
|
-
try {
|
|
135
|
-
const delayed = batch ? ["Delayed 1", "Delayed 2"] : ["Delayed"];
|
|
136
|
-
const options = { delay: Temporal.Duration.from({ milliseconds: 100 }) };
|
|
137
|
-
if (batch) await mq.enqueueMany(delayed, options);
|
|
138
|
-
else await mq.enqueue(delayed[0], options);
|
|
139
|
-
await mq.enqueue("Immediate");
|
|
140
|
-
await waitFor(() => messages.length >= delayed.length + 1, 15e3);
|
|
141
|
-
assertEquals(messages, ["Immediate", ...delayed]);
|
|
142
|
-
} finally {
|
|
143
|
-
controller.abort();
|
|
144
|
-
await listening;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
test("InProcessMessageQueue.getDepth()", async () => {
|
|
149
|
-
const mq = new InProcessMessageQueue();
|
|
150
|
-
assertEquals(await mq.getDepth(), {
|
|
151
|
-
queued: 0,
|
|
152
|
-
ready: 0,
|
|
153
|
-
delayed: 0
|
|
154
|
-
});
|
|
155
|
-
await mq.enqueue("Ready message");
|
|
156
|
-
await mq.enqueue("Delayed message", { delay: Temporal.Duration.from({ seconds: 1 }) });
|
|
157
|
-
assertEquals(await mq.getDepth(), {
|
|
158
|
-
queued: 2,
|
|
159
|
-
ready: 1,
|
|
160
|
-
delayed: 1
|
|
161
|
-
});
|
|
162
|
-
const messages = [];
|
|
163
|
-
const controller = new AbortController();
|
|
164
|
-
const listening = mq.listen((message) => {
|
|
165
|
-
messages.push(message);
|
|
166
|
-
if (messages.length >= 2) controller.abort();
|
|
167
|
-
}, { signal: controller.signal });
|
|
168
|
-
await waitFor(() => messages.length >= 2, 15e3);
|
|
169
|
-
await listening;
|
|
170
|
-
assertEquals(await mq.getDepth(), {
|
|
171
|
-
queued: 0,
|
|
172
|
-
ready: 0,
|
|
173
|
-
delayed: 0
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
test("InProcessMessageQueue.getDepth() snapshots delayed batches", async () => {
|
|
177
|
-
const mq = new InProcessMessageQueue();
|
|
178
|
-
const messages = ["first", "second"];
|
|
179
|
-
await mq.enqueueMany(messages, { delay: Temporal.Duration.from({ milliseconds: 250 }) });
|
|
180
|
-
messages.length = 0;
|
|
181
|
-
assertEquals(await mq.getDepth(), {
|
|
182
|
-
queued: 2,
|
|
183
|
-
ready: 0,
|
|
184
|
-
delayed: 2
|
|
185
|
-
});
|
|
186
|
-
const handled = [];
|
|
187
|
-
const controller = new AbortController();
|
|
188
|
-
const listening = mq.listen((message) => {
|
|
189
|
-
handled.push(message);
|
|
190
|
-
if (handled.length >= 2) controller.abort();
|
|
191
|
-
}, { signal: controller.signal });
|
|
192
|
-
await waitFor(() => handled.length >= 2, 15e3);
|
|
193
|
-
await listening;
|
|
194
|
-
assertEquals(handled, ["first", "second"]);
|
|
195
|
-
});
|
|
196
|
-
test("InProcessMessageQueue.getDepth() excludes in-flight messages", async () => {
|
|
197
|
-
const mq = new InProcessMessageQueue();
|
|
198
|
-
let resolveHandler;
|
|
199
|
-
const controller = new AbortController();
|
|
200
|
-
const handled = new Promise((resolve) => {
|
|
201
|
-
resolveHandler = resolve;
|
|
202
|
-
});
|
|
203
|
-
let notifyStarted = () => {};
|
|
204
|
-
const handlerStarted = new Promise((resolve) => {
|
|
205
|
-
notifyStarted = resolve;
|
|
206
|
-
});
|
|
207
|
-
const listening = mq.listen(async () => {
|
|
208
|
-
notifyStarted();
|
|
209
|
-
await handled;
|
|
210
|
-
controller.abort();
|
|
211
|
-
}, { signal: controller.signal });
|
|
212
|
-
try {
|
|
213
|
-
await mq.enqueue("in-flight");
|
|
214
|
-
await handlerStarted;
|
|
215
|
-
assertEquals(await mq.getDepth(), {
|
|
216
|
-
queued: 0,
|
|
217
|
-
ready: 0,
|
|
218
|
-
delayed: 0
|
|
219
|
-
});
|
|
220
|
-
} finally {
|
|
221
|
-
resolveHandler?.();
|
|
222
|
-
controller.abort();
|
|
223
|
-
await listening;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
test("InProcessMessageQueue delayed enqueue uses the internal ready path", async () => {
|
|
227
|
-
class RejectingReadyQueue extends InProcessMessageQueue {
|
|
228
|
-
enqueue(message, options) {
|
|
229
|
-
if (options?.delay == null) return Promise.reject(/* @__PURE__ */ new Error("ready enqueue should not be called"));
|
|
230
|
-
return super.enqueue(message, options);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const mq = new RejectingReadyQueue({ pollInterval: { milliseconds: 10 } });
|
|
234
|
-
const messages = [];
|
|
235
|
-
const controller = new AbortController();
|
|
236
|
-
const listening = mq.listen((message) => {
|
|
237
|
-
messages.push(message);
|
|
238
|
-
controller.abort();
|
|
239
|
-
}, { signal: controller.signal });
|
|
240
|
-
try {
|
|
241
|
-
await mq.enqueue("delayed", { delay: Temporal.Duration.from({ milliseconds: 10 }) });
|
|
242
|
-
await waitFor(() => messages.length > 0, 2e3);
|
|
243
|
-
assertEquals(messages, ["delayed"]);
|
|
244
|
-
} finally {
|
|
245
|
-
controller.abort();
|
|
246
|
-
await listening;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
test("InProcessMessageQueue delayed enqueueMany uses the internal ready path", async () => {
|
|
250
|
-
class RejectingReadyQueue extends InProcessMessageQueue {
|
|
251
|
-
enqueueMany(messages, options) {
|
|
252
|
-
if (options?.delay == null) return Promise.reject(/* @__PURE__ */ new Error("ready enqueueMany should not be called"));
|
|
253
|
-
return super.enqueueMany(messages, options);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
const mq = new RejectingReadyQueue({ pollInterval: { milliseconds: 10 } });
|
|
257
|
-
const messages = [];
|
|
258
|
-
const controller = new AbortController();
|
|
259
|
-
const listening = mq.listen((message) => {
|
|
260
|
-
messages.push(message);
|
|
261
|
-
if (messages.length >= 2) controller.abort();
|
|
262
|
-
}, { signal: controller.signal });
|
|
263
|
-
try {
|
|
264
|
-
await mq.enqueueMany(["first", "second"], { delay: Temporal.Duration.from({ milliseconds: 10 }) });
|
|
265
|
-
await waitFor(() => messages.length >= 2, 2e3);
|
|
266
|
-
assertEquals(messages, ["first", "second"]);
|
|
267
|
-
} finally {
|
|
268
|
-
controller.abort();
|
|
269
|
-
await listening;
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
test("InProcessMessageQueue orderingKey", async (t) => {
|
|
273
|
-
const mq = new InProcessMessageQueue();
|
|
274
|
-
const orderTracker = {
|
|
275
|
-
keyA: [],
|
|
276
|
-
keyB: [],
|
|
277
|
-
noKey: []
|
|
278
|
-
};
|
|
279
|
-
const allMessages = [];
|
|
280
|
-
const controller = new AbortController();
|
|
281
|
-
const listening = mq.listen((message) => {
|
|
282
|
-
allMessages.push(message);
|
|
283
|
-
const trackKey = message.key ?? "noKey";
|
|
284
|
-
if (trackKey in orderTracker) orderTracker[trackKey].push(message.value);
|
|
285
|
-
}, controller);
|
|
286
|
-
await t.step("enqueue with ordering key", async () => {
|
|
287
|
-
await mq.enqueue({
|
|
288
|
-
key: "keyA",
|
|
289
|
-
value: 1
|
|
290
|
-
}, { orderingKey: "keyA" });
|
|
291
|
-
await mq.enqueue({
|
|
292
|
-
key: "keyB",
|
|
293
|
-
value: 1
|
|
294
|
-
}, { orderingKey: "keyB" });
|
|
295
|
-
await mq.enqueue({
|
|
296
|
-
key: "keyA",
|
|
297
|
-
value: 2
|
|
298
|
-
}, { orderingKey: "keyA" });
|
|
299
|
-
await mq.enqueue({
|
|
300
|
-
key: "keyB",
|
|
301
|
-
value: 2
|
|
302
|
-
}, { orderingKey: "keyB" });
|
|
303
|
-
await mq.enqueue({
|
|
304
|
-
key: "keyA",
|
|
305
|
-
value: 3
|
|
306
|
-
}, { orderingKey: "keyA" });
|
|
307
|
-
await mq.enqueue({
|
|
308
|
-
key: "keyB",
|
|
309
|
-
value: 3
|
|
310
|
-
}, { orderingKey: "keyB" });
|
|
311
|
-
await mq.enqueue({
|
|
312
|
-
key: null,
|
|
313
|
-
value: 1
|
|
314
|
-
});
|
|
315
|
-
await mq.enqueue({
|
|
316
|
-
key: null,
|
|
317
|
-
value: 2
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
await waitFor(() => allMessages.length >= 8, 3e4);
|
|
321
|
-
await t.step("verify ordering key order", () => {
|
|
322
|
-
assertEquals(orderTracker.keyA, [
|
|
323
|
-
1,
|
|
324
|
-
2,
|
|
325
|
-
3
|
|
326
|
-
], "Messages with orderingKey 'keyA' should be processed in order");
|
|
327
|
-
assertEquals(orderTracker.keyB, [
|
|
328
|
-
1,
|
|
329
|
-
2,
|
|
330
|
-
3
|
|
331
|
-
], "Messages with orderingKey 'keyB' should be processed in order");
|
|
332
|
-
});
|
|
333
|
-
await t.step("verify messages without ordering key", () => {
|
|
334
|
-
assertEquals(orderTracker.noKey.length, 2, "Messages without ordering key should all be received");
|
|
335
|
-
assert(orderTracker.noKey.includes(1) && orderTracker.noKey.includes(2), "Messages without ordering key should contain values 1 and 2");
|
|
336
|
-
});
|
|
337
|
-
controller.abort();
|
|
338
|
-
await listening;
|
|
339
|
-
});
|
|
340
|
-
test("MessageQueue.nativeRetrial", async (t) => {
|
|
341
|
-
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") await t.step("DenoKvMessageQueue", async () => {
|
|
342
|
-
const packageName = () => "@fedify/denokv";
|
|
343
|
-
const { DenoKvMessageQueue } = await import(packageName());
|
|
344
|
-
const mq = new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
345
|
-
assert(mq.nativeRetrial);
|
|
346
|
-
assert(mq.maxMessageSize < 64 * 1024);
|
|
347
|
-
for (const item of [
|
|
348
|
-
[],
|
|
349
|
-
{},
|
|
350
|
-
.1,
|
|
351
|
-
"",
|
|
352
|
-
"é",
|
|
353
|
-
"한",
|
|
354
|
-
"x".repeat(100),
|
|
355
|
-
true,
|
|
356
|
-
"a".repeat(1e3) + "한"
|
|
357
|
-
]) {
|
|
358
|
-
const items = [];
|
|
359
|
-
const message = () => ({
|
|
360
|
-
type: "inbox",
|
|
361
|
-
payload: { items }
|
|
362
|
-
});
|
|
363
|
-
while (estimateQueuedMessageSize(message()) < mq.maxMessageSize - 64) items.push(item);
|
|
364
|
-
items.pop();
|
|
365
|
-
await mq.enqueue(message());
|
|
366
|
-
}
|
|
367
|
-
await disposeMessageQueue(mq);
|
|
368
|
-
});
|
|
369
|
-
await t.step("WorkersMessageQueue mock", () => {
|
|
370
|
-
class MockQueue {
|
|
371
|
-
send(_message, _options) {
|
|
372
|
-
return Promise.resolve();
|
|
373
|
-
}
|
|
374
|
-
sendBatch(_messages, _options) {
|
|
375
|
-
return Promise.resolve();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
class TestWorkersMessageQueue {
|
|
379
|
-
nativeRetrial = true;
|
|
380
|
-
#queue;
|
|
381
|
-
constructor(queue) {
|
|
382
|
-
this.#queue = queue;
|
|
383
|
-
}
|
|
384
|
-
enqueue(message) {
|
|
385
|
-
return this.#queue.send(message);
|
|
386
|
-
}
|
|
387
|
-
enqueueMany(messages) {
|
|
388
|
-
return this.#queue.sendBatch(messages);
|
|
389
|
-
}
|
|
390
|
-
listen() {
|
|
391
|
-
throw new TypeError("WorkersMessageQueue does not support listen()");
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
test("ParallelMessageQueue inherits nativeDeduplication", () => {
|
|
398
|
-
class NativeDeduplicationQueue {
|
|
399
|
-
nativeDeduplication = true;
|
|
400
|
-
enqueue() {
|
|
401
|
-
return Promise.resolve();
|
|
402
|
-
}
|
|
403
|
-
listen() {
|
|
404
|
-
return Promise.resolve();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
assert(new ParallelMessageQueue(new NativeDeduplicationQueue(), 5).nativeDeduplication);
|
|
408
|
-
});
|
|
409
|
-
test("ParallelMessageQueue inherits atomicEnqueueMany", () => {
|
|
410
|
-
class NonAtomicBatchQueue {
|
|
411
|
-
atomicEnqueueMany = false;
|
|
412
|
-
enqueue() {
|
|
413
|
-
return Promise.resolve();
|
|
414
|
-
}
|
|
415
|
-
enqueueMany() {
|
|
416
|
-
return Promise.resolve();
|
|
417
|
-
}
|
|
418
|
-
listen() {
|
|
419
|
-
return Promise.resolve();
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
assertFalse(new ParallelMessageQueue(new NonAtomicBatchQueue(), 5).atomicEnqueueMany);
|
|
423
|
-
});
|
|
424
|
-
test("ParallelMessageQueue forwards deduplicationKey to the wrapped queue", async () => {
|
|
425
|
-
class RecordingQueue {
|
|
426
|
-
nativeDeduplication = true;
|
|
427
|
-
singles = [];
|
|
428
|
-
batches = [];
|
|
429
|
-
enqueue(_message, options) {
|
|
430
|
-
this.singles.push(options);
|
|
431
|
-
return Promise.resolve();
|
|
432
|
-
}
|
|
433
|
-
enqueueMany(_messages, options) {
|
|
434
|
-
this.batches.push(options);
|
|
435
|
-
return Promise.resolve();
|
|
436
|
-
}
|
|
437
|
-
listen() {
|
|
438
|
-
return Promise.resolve();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
const inner = new RecordingQueue();
|
|
442
|
-
const workers = new ParallelMessageQueue(inner, 5);
|
|
443
|
-
await workers.enqueue({ x: 1 }, { deduplicationKey: "k1" });
|
|
444
|
-
await workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k2" });
|
|
445
|
-
assertEquals(inner.singles[0]?.deduplicationKey, "k1");
|
|
446
|
-
assertEquals(inner.batches[0]?.deduplicationKey, "k2");
|
|
447
|
-
});
|
|
448
|
-
test("ParallelMessageQueue rejects a deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
|
|
449
|
-
class NoBulkQueue {
|
|
450
|
-
nativeDeduplication = true;
|
|
451
|
-
enqueued = [];
|
|
452
|
-
enqueue(message) {
|
|
453
|
-
this.enqueued.push(message);
|
|
454
|
-
return Promise.resolve();
|
|
455
|
-
}
|
|
456
|
-
listen() {
|
|
457
|
-
return Promise.resolve();
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
const inner = new NoBulkQueue();
|
|
461
|
-
const workers = new ParallelMessageQueue(inner, 5);
|
|
462
|
-
assertFalse(workers.atomicEnqueueMany);
|
|
463
|
-
await assertRejects(() => workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k" }), TypeError, "enqueueMany");
|
|
464
|
-
assertEquals(inner.enqueued.length, 0);
|
|
465
|
-
});
|
|
466
|
-
test("ParallelMessageQueue falls back to enqueue() for a single deduplicated item when the wrapped queue lacks enqueueMany", async () => {
|
|
467
|
-
class NoBulkQueue {
|
|
468
|
-
nativeDeduplication = true;
|
|
469
|
-
enqueued = [];
|
|
470
|
-
options = [];
|
|
471
|
-
enqueue(message, options) {
|
|
472
|
-
this.enqueued.push(message);
|
|
473
|
-
this.options.push(options);
|
|
474
|
-
return Promise.resolve();
|
|
475
|
-
}
|
|
476
|
-
listen() {
|
|
477
|
-
return Promise.resolve();
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
const inner = new NoBulkQueue();
|
|
481
|
-
await new ParallelMessageQueue(inner, 5).enqueueMany([{ x: 1 }], { deduplicationKey: "k" });
|
|
482
|
-
assertEquals(inner.enqueued, [{ x: 1 }]);
|
|
483
|
-
assertEquals(inner.options[0]?.deduplicationKey, "k");
|
|
484
|
-
});
|
|
485
|
-
test("ParallelMessageQueue still fans out a non-deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
|
|
486
|
-
class NoBulkQueue {
|
|
487
|
-
enqueued = [];
|
|
488
|
-
enqueue(message) {
|
|
489
|
-
this.enqueued.push(message);
|
|
490
|
-
return Promise.resolve();
|
|
491
|
-
}
|
|
492
|
-
listen() {
|
|
493
|
-
return Promise.resolve();
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
const inner = new NoBulkQueue();
|
|
497
|
-
await new ParallelMessageQueue(inner, 5).enqueueMany([
|
|
498
|
-
{ x: 1 },
|
|
499
|
-
{ x: 2 },
|
|
500
|
-
{ x: 3 }
|
|
501
|
-
]);
|
|
502
|
-
assertEquals(inner.enqueued.length, 3);
|
|
503
|
-
});
|
|
504
|
-
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
|
505
|
-
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
|
|
506
|
-
const packageName = () => "@fedify/denokv";
|
|
507
|
-
const { DenoKvMessageQueue } = await import(packageName());
|
|
508
|
-
queues.DenoKvMessageQueue = async () => new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
509
|
-
}
|
|
510
|
-
for (const mqName in queues) test({
|
|
511
|
-
name: `ParallelMessageQueue [${mqName}]`,
|
|
512
|
-
ignore: "Bun" in globalThis,
|
|
513
|
-
async fn(t) {
|
|
514
|
-
const mq = await queues[mqName]();
|
|
515
|
-
const workers = new ParallelMessageQueue(mq, 5);
|
|
516
|
-
await t.step("nativeRetrial property inheritance", () => {
|
|
517
|
-
assertEquals(workers.nativeRetrial, mq.nativeRetrial);
|
|
518
|
-
});
|
|
519
|
-
await t.step("nativeDeduplication property inheritance", () => {
|
|
520
|
-
assertEquals(workers.nativeDeduplication, mq.nativeDeduplication);
|
|
521
|
-
});
|
|
522
|
-
await t.step("atomicEnqueueMany capability propagation", () => {
|
|
523
|
-
assertEquals(workers.atomicEnqueueMany, mq.enqueueMany == null ? false : mq.atomicEnqueueMany);
|
|
524
|
-
});
|
|
525
|
-
await t.step("getDepth() delegation", async () => {
|
|
526
|
-
if (mq.getDepth == null) assertEquals(workers.getDepth, void 0);
|
|
527
|
-
else assertEquals(await workers.getDepth?.(), await mq.getDepth());
|
|
528
|
-
});
|
|
529
|
-
const messages = [];
|
|
530
|
-
const controller = new AbortController();
|
|
531
|
-
const listening = workers.listen(async (message) => {
|
|
532
|
-
for (let i = 0, cnt = 5 + Math.random() * 5; i < cnt; i++) await delay(250);
|
|
533
|
-
messages.push(message);
|
|
534
|
-
}, controller);
|
|
535
|
-
await t.step("enqueue() [single]", async () => {
|
|
536
|
-
await workers.enqueue("Hello, world!");
|
|
537
|
-
});
|
|
538
|
-
await waitFor(() => messages.length > 0, 15e3);
|
|
539
|
-
await t.step("listen() [single]", () => {
|
|
540
|
-
assertEquals(messages, ["Hello, world!"]);
|
|
541
|
-
});
|
|
542
|
-
messages.pop();
|
|
543
|
-
await t.step("enqueue() [multiple]", async () => {
|
|
544
|
-
for (let i = 0; i < 20; i++) await workers.enqueue(`Hello, ${i}!`);
|
|
545
|
-
});
|
|
546
|
-
await t.step("listen() [multiple]", async () => {
|
|
547
|
-
await delay(3e3);
|
|
548
|
-
assertGreaterOrEqual(messages.length, 5);
|
|
549
|
-
await waitFor(() => messages.length >= 20, 15e3);
|
|
550
|
-
assertEquals(messages.length, 20);
|
|
551
|
-
});
|
|
552
|
-
await waitFor(() => messages.length >= 20, 15e3);
|
|
553
|
-
while (messages.length > 0) messages.pop();
|
|
554
|
-
await t.step("enqueueMany()", async () => {
|
|
555
|
-
const messages = Array.from({ length: 20 }, (_, i) => `Hello, ${i}!`);
|
|
556
|
-
await workers.enqueueMany(messages);
|
|
557
|
-
});
|
|
558
|
-
await t.step("listen() [multiple]", async () => {
|
|
559
|
-
await delay(3e3);
|
|
560
|
-
assertGreaterOrEqual(messages.length, 5);
|
|
561
|
-
await waitFor(() => messages.length >= 20, 15e3);
|
|
562
|
-
assertEquals(messages.length, 20);
|
|
563
|
-
});
|
|
564
|
-
await waitFor(() => messages.length >= 20, 15e3);
|
|
565
|
-
controller.abort();
|
|
566
|
-
await listening;
|
|
567
|
-
await disposeMessageQueue(mq);
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
async function waitFor(predicate, timeoutMs) {
|
|
571
|
-
const started = Date.now();
|
|
572
|
-
while (!predicate()) {
|
|
573
|
-
await delay(500);
|
|
574
|
-
if (Date.now() - started > timeoutMs) throw new Error("Timeout");
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
test("ParallelMessageQueue inherits maxMessageSize", () => {
|
|
578
|
-
class BoundedQueue {
|
|
579
|
-
maxMessageSize = 1024;
|
|
580
|
-
enqueue() {
|
|
581
|
-
return Promise.resolve();
|
|
582
|
-
}
|
|
583
|
-
listen() {
|
|
584
|
-
return Promise.resolve();
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
assertEquals(new ParallelMessageQueue(new BoundedQueue(), 2).maxMessageSize, 1024);
|
|
588
|
-
assertEquals(new ParallelMessageQueue(new InProcessMessageQueue(), 2).maxMessageSize, void 0);
|
|
589
|
-
});
|
|
590
|
-
//#endregion
|
|
591
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import "temporal-polyfill";
|
|
2
|
-
import "urlpattern-polyfill";
|
|
3
|
-
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
|
|
5
|
-
import "../std__assert-DvMDRPes.mjs";
|
|
6
|
-
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
7
|
-
import { t as acceptsJsonLd } from "../negotiation-BAKO9nih.mjs";
|
|
8
|
-
import { test } from "@fedify/fixture";
|
|
9
|
-
//#region src/federation/negotiation.test.ts
|
|
10
|
-
test("acceptsJsonLd()", () => {
|
|
11
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
|
|
12
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json" } })));
|
|
13
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/json" } })));
|
|
14
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.5, text/html; q=0.8" } })));
|
|
15
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.4, application/xhtml+xml; q=0.9" } })));
|
|
16
|
-
});
|
|
17
|
-
//#endregion
|
|
18
|
-
export {};
|