@fedify/fedify 2.4.0-dev.1508 → 2.4.0-dev.1528
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/{assert-DvVHoIZ0.mjs → assert-OguE97r2.mjs} +1 -1
- package/dist/{assert_instance_of-CxoC8bVq.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
- package/dist/{assert_not_equals-C8vcTTA3.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
- package/dist/{assert_rejects-DAdaaIWM.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
- package/dist/{assert_strict_equals-BzqyKuYL.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
- package/dist/{assert_throws-zN79lgIC.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
- package/dist/{builder-DlWCek6Z.mjs → builder-B6myMguW.mjs} +3 -23
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +3 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/transformers.test.mjs +5 -5
- package/dist/{context-CYF8X0ft.d.cts → context-BBVLF7lx.d.cts} +272 -543
- package/dist/{context-BF5B4ZDk.d.ts → context-BU6jSQdo.d.ts} +272 -542
- package/dist/{context-BBRTgkrs.mjs → context-DVoTs_wM.mjs} +2 -8
- package/dist/{deno-nexucTAX.mjs → deno-CVNsRJe9.mjs} +1 -1
- package/dist/{docloader-DAdEN549.mjs → docloader-CB8AGpw3.mjs} +3 -3
- package/dist/federation/builder.test.mjs +5 -5
- package/dist/federation/circuit-breaker.test.mjs +5 -5
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +13 -13
- package/dist/federation/idempotency.test.mjs +6 -6
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +5 -5
- package/dist/federation/kv.test.mjs +3 -3
- package/dist/federation/metrics.test.mjs +4 -4
- package/dist/federation/middleware.test.mjs +19 -200
- package/dist/federation/mod.cjs +259 -3
- package/dist/federation/mod.d.cts +4 -4
- package/dist/federation/mod.d.ts +4 -4
- package/dist/federation/mod.js +257 -1
- package/dist/federation/mq.test.mjs +261 -103
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +5 -5
- package/dist/federation/send.test.mjs +10 -10
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +6 -6
- package/dist/{http-Dv3147TL.js → http-B0-9u_1F.js} +1 -1
- package/dist/{http-BCj9dlA_.cjs → http-EkV7OslM.cjs} +1 -1
- package/dist/{http-inQqS3yx.mjs → http-L7wqkbZR.mjs} +4 -4
- package/dist/{key-CGrr6-I2.mjs → key-Ct8zNgGk.mjs} +2 -2
- package/dist/{kv-cache-C3qkFkbt.mjs → kv-cache-CUT9OGpX.mjs} +1 -1
- package/dist/{kv-cache-c8X6svwE.cjs → kv-cache-CbB50co6.cjs} +1 -1
- package/dist/{kv-cache-C2oTEXyb.js → kv-cache-Dh8ZoQfC.js} +1 -1
- package/dist/{ld-fnWaNT8y.mjs → ld-D6I7H18J.mjs} +3 -3
- package/dist/{metrics-C5hMINAa.mjs → metrics-DvClPYaE.mjs} +1 -1
- package/dist/{middleware-DeVzbg1I.cjs → middleware-B0ujKP-0.cjs} +30 -690
- package/dist/{middleware-CQlq6ykI.mjs → middleware-CGqUj4XY.mjs} +1 -1
- package/dist/{middleware-vQ_ZpgcX.js → middleware-DX9Fd37u.js} +31 -679
- package/dist/{middleware-Dl2nyVgB.mjs → middleware-RxFBNV2C.mjs} +46 -306
- package/dist/{mod-BHEB3xhE.d.cts → mod-C0F6kvgS.d.cts} +1 -1
- package/dist/{mod-4WGAuR6X.d.ts → mod-vPYVoa5n.d.ts} +1 -1
- package/dist/mod.cjs +6 -6
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +5 -5
- package/dist/{mq-DXMt_qCY.d.cts → mq-D-nlpY04.d.ts} +0 -34
- package/dist/{mq-B5_hohs7.d.ts → mq-D8uSFzxe.d.cts} +0 -34
- package/dist/nodeinfo/client.test.mjs +3 -3
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
- package/dist/{owner-Bq2eZyO_.mjs → owner-BqPUA8Z6.mjs} +2 -2
- package/dist/{proof-DZCjcFCd.mjs → proof-BJKoRFBc.mjs} +5 -5
- package/dist/{proof-CTG9azxN.js → proof-DCCmmEuJ.js} +1 -1
- package/dist/{proof-Buz7I8wj.cjs → proof-eZme7HYR.cjs} +1 -1
- package/dist/{send-B253S5gN.mjs → send-DVtEjoJ6.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +8 -8
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +8 -8
- package/dist/{std__assert-Dh6uLf_q.mjs → std__assert-BBjXFNOb.mjs} +4 -4
- package/dist/{temporal-d6TshGjq.mjs → temporal-B06FcmVK.mjs} +1 -1
- package/dist/testing/mod.d.mts +8 -1037
- package/dist/testing/mod.mjs +2 -3
- package/dist/utils/docloader.test.mjs +6 -6
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +7 -9
- package/dist/codec-CmlPqjNX.mjs +0 -103
- package/dist/federation/tasks/codec.test.d.mts +0 -2
- package/dist/federation/tasks/codec.test.mjs +0 -292
- package/dist/federation/tasks/enqueue.test.d.mts +0 -2
- package/dist/federation/tasks/enqueue.test.mjs +0 -992
- package/dist/federation/tasks/tasks.test.d.mts +0 -2
- package/dist/federation/tasks/tasks.test.mjs +0 -555
- package/dist/mq-03vS-C9P.mjs +0 -276
- package/dist/testing-Dy-WhqpN.mjs +0 -77
- /package/dist/{accept-CgDcxvjV.mjs → accept-CPkZzmGN.mjs} +0 -0
- /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{assert_equals-PBVKNMJd.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
- /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
- /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
- /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
- /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
- /package/dist/{keys-CSYsOMFG.mjs → keys-DGu1NFwu.mjs} +0 -0
- /package/dist/{kv-CIvR3Non.mjs → kv-rV3vodCc.mjs} +0 -0
- /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
- /package/dist/{public-audience-c9zmYKgA.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
- /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
- /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
|
@@ -1,13 +1,268 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { n as assertGreater } from "../std__assert-
|
|
6
|
-
import { n as assertGreaterOrEqual, r as assertFalse
|
|
7
|
-
import { t as assert } from "../assert-
|
|
8
|
-
import { n as ParallelMessageQueue, t as InProcessMessageQueue } from "../mq-03vS-C9P.mjs";
|
|
9
|
-
import { delay } from "es-toolkit";
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { n as assertGreater } from "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { n as assertGreaterOrEqual, r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
10
8
|
import { test } from "@fedify/fixture";
|
|
9
|
+
import { delay } from "es-toolkit";
|
|
10
|
+
//#region src/federation/mq.ts
|
|
11
|
+
/**
|
|
12
|
+
* A message queue that processes messages in the same process.
|
|
13
|
+
* Do not use this in production as it does neither persist messages nor
|
|
14
|
+
* distribute them across multiple processes.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.5.0
|
|
17
|
+
*/
|
|
18
|
+
var InProcessMessageQueue = class {
|
|
19
|
+
#messages;
|
|
20
|
+
#monitors;
|
|
21
|
+
#pollIntervalMs;
|
|
22
|
+
#delayedMessages;
|
|
23
|
+
/**
|
|
24
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
25
|
+
* sequential processing for messages with the same key.
|
|
26
|
+
*/
|
|
27
|
+
#processingKeys;
|
|
28
|
+
/**
|
|
29
|
+
* In-process message queue does not provide native retry mechanisms.
|
|
30
|
+
* @since 1.7.0
|
|
31
|
+
*/
|
|
32
|
+
nativeRetrial = false;
|
|
33
|
+
/**
|
|
34
|
+
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
|
35
|
+
* @param options Additional options for the in-process message queue.
|
|
36
|
+
*/
|
|
37
|
+
constructor(options = {}) {
|
|
38
|
+
this.#messages = [];
|
|
39
|
+
this.#monitors = {};
|
|
40
|
+
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
41
|
+
this.#delayedMessages = 0;
|
|
42
|
+
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
43
|
+
}
|
|
44
|
+
enqueue(message, options) {
|
|
45
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
46
|
+
if (delay > 0) {
|
|
47
|
+
this.#delayedMessages++;
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
this.#delayedMessages--;
|
|
50
|
+
this.#enqueueReady(message, options);
|
|
51
|
+
}, delay);
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
}
|
|
54
|
+
this.#enqueueReady(message, options);
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
#enqueueReady(message, options) {
|
|
58
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
59
|
+
this.#messages.push({
|
|
60
|
+
message,
|
|
61
|
+
orderingKey
|
|
62
|
+
});
|
|
63
|
+
this.#notifyMonitors();
|
|
64
|
+
}
|
|
65
|
+
#notifyMonitors() {
|
|
66
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
67
|
+
}
|
|
68
|
+
enqueueMany(messages, options) {
|
|
69
|
+
if (messages.length === 0) return Promise.resolve();
|
|
70
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
71
|
+
if (delay > 0) {
|
|
72
|
+
const delayedCount = messages.length;
|
|
73
|
+
const deferredMessages = [...messages];
|
|
74
|
+
this.#delayedMessages += delayedCount;
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
this.#delayedMessages -= delayedCount;
|
|
77
|
+
this.#enqueueManyReady(deferredMessages, options);
|
|
78
|
+
}, delay);
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
}
|
|
81
|
+
this.#enqueueManyReady(messages, options);
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
84
|
+
#enqueueManyReady(messages, options) {
|
|
85
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
86
|
+
for (const message of messages) this.#messages.push({
|
|
87
|
+
message,
|
|
88
|
+
orderingKey
|
|
89
|
+
});
|
|
90
|
+
this.#notifyMonitors();
|
|
91
|
+
}
|
|
92
|
+
async listen(handler, options = {}) {
|
|
93
|
+
const signal = options.signal;
|
|
94
|
+
while (signal == null || !signal.aborted) {
|
|
95
|
+
const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
|
|
96
|
+
if (idx >= 0) {
|
|
97
|
+
const { message, orderingKey } = this.#messages.splice(idx, 1)[0];
|
|
98
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
99
|
+
try {
|
|
100
|
+
await handler(message);
|
|
101
|
+
} finally {
|
|
102
|
+
if (orderingKey != null) this.#processingKeys.delete(orderingKey);
|
|
103
|
+
}
|
|
104
|
+
} else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
|
|
105
|
+
else await this.#wait(10, signal);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
getDepth() {
|
|
109
|
+
const ready = this.#messages.length;
|
|
110
|
+
const delayed = this.#delayedMessages;
|
|
111
|
+
return Promise.resolve({
|
|
112
|
+
queued: ready + delayed,
|
|
113
|
+
ready,
|
|
114
|
+
delayed
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
#wait(ms, signal) {
|
|
118
|
+
let timer = null;
|
|
119
|
+
return Promise.any([new Promise((resolve) => {
|
|
120
|
+
signal?.addEventListener("abort", () => {
|
|
121
|
+
if (timer != null) clearTimeout(timer);
|
|
122
|
+
resolve();
|
|
123
|
+
}, { once: true });
|
|
124
|
+
const monitorId = crypto.randomUUID();
|
|
125
|
+
this.#monitors[monitorId] = () => {
|
|
126
|
+
delete this.#monitors[monitorId];
|
|
127
|
+
if (timer != null) clearTimeout(timer);
|
|
128
|
+
resolve();
|
|
129
|
+
};
|
|
130
|
+
}), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* A message queue that processes messages in parallel. It takes another
|
|
135
|
+
* {@link MessageQueue}, and processes messages in parallel up to a certain
|
|
136
|
+
* number of workers.
|
|
137
|
+
*
|
|
138
|
+
* Actually, it's rather a decorator than a queue itself.
|
|
139
|
+
*
|
|
140
|
+
* Note that the workers do not run in truly parallel, in the sense that they
|
|
141
|
+
* are not running in separate threads or processes. They are running in the
|
|
142
|
+
* same process, but are scheduled to run in parallel. Hence, this is useful
|
|
143
|
+
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
144
|
+
* workloads.
|
|
145
|
+
*
|
|
146
|
+
* When using `ParallelMessageQueue`, the ordering guarantee is preserved
|
|
147
|
+
* *only if* the underlying queue implementation delivers messages in a wrapper
|
|
148
|
+
* format that includes the `__fedify_ordering_key__` property. Currently,
|
|
149
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
150
|
+
* For other queue implementations (e.g., `InProcessMessageQueue`,
|
|
151
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
152
|
+
* `AmqpMessageQueue`), the ordering key cannot be detected by
|
|
153
|
+
* `ParallelMessageQueue`, so ordering guarantees are handled by those
|
|
154
|
+
* implementations directly rather than at the `ParallelMessageQueue` level.
|
|
155
|
+
*
|
|
156
|
+
* Messages with the same ordering key will never be processed concurrently
|
|
157
|
+
* by different workers, ensuring sequential processing within each key.
|
|
158
|
+
* Messages with different ordering keys (or no ordering key) can still be
|
|
159
|
+
* processed in parallel.
|
|
160
|
+
*
|
|
161
|
+
* @since 1.0.0
|
|
162
|
+
*/
|
|
163
|
+
var ParallelMessageQueue = class ParallelMessageQueue {
|
|
164
|
+
queue;
|
|
165
|
+
workers;
|
|
166
|
+
/**
|
|
167
|
+
* Inherits the native retry capability from the wrapped queue.
|
|
168
|
+
* @since 1.7.0
|
|
169
|
+
*/
|
|
170
|
+
nativeRetrial;
|
|
171
|
+
getDepth;
|
|
172
|
+
/**
|
|
173
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
174
|
+
* sequential processing for messages with the same key.
|
|
175
|
+
*/
|
|
176
|
+
#processingKeys = /* @__PURE__ */ new Set();
|
|
177
|
+
/**
|
|
178
|
+
* Pending messages waiting for their ordering key to become available.
|
|
179
|
+
*/
|
|
180
|
+
#pendingMessages = [];
|
|
181
|
+
/**
|
|
182
|
+
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
183
|
+
* number of workers.
|
|
184
|
+
* @param queue The message queue to use under the hood. Note that
|
|
185
|
+
* {@link ParallelMessageQueue} cannot be nested.
|
|
186
|
+
* @param workers The number of workers to process messages in parallel.
|
|
187
|
+
* @throws {TypeError} If the given queue is an instance of
|
|
188
|
+
* {@link ParallelMessageQueue}.
|
|
189
|
+
*/
|
|
190
|
+
constructor(queue, workers) {
|
|
191
|
+
if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
|
|
192
|
+
this.queue = queue;
|
|
193
|
+
this.workers = workers;
|
|
194
|
+
this.nativeRetrial = queue.nativeRetrial;
|
|
195
|
+
if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
|
|
196
|
+
}
|
|
197
|
+
enqueue(message, options) {
|
|
198
|
+
return this.queue.enqueue(message, options);
|
|
199
|
+
}
|
|
200
|
+
async enqueueMany(messages, options) {
|
|
201
|
+
if (this.queue.enqueueMany == null) {
|
|
202
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
203
|
+
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
204
|
+
else if (errors.length === 1) throw errors[0];
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
await this.queue.enqueueMany(messages, options);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Extracts ordering key from a message if present.
|
|
211
|
+
*
|
|
212
|
+
* This method only works for queue implementations that deliver messages
|
|
213
|
+
* in the wrapper format with `__fedify_ordering_key__` property. Currently,
|
|
214
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
215
|
+
*
|
|
216
|
+
* For other queue implementations (`InProcessMessageQueue`,
|
|
217
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
218
|
+
* `AmqpMessageQueue`), messages are delivered as raw payloads without the
|
|
219
|
+
* wrapper, so the ordering key cannot be detected here. Those
|
|
220
|
+
* implementations handle ordering guarantees internally.
|
|
221
|
+
*/
|
|
222
|
+
#extractOrderingKey(message) {
|
|
223
|
+
if (message != null && typeof message === "object") {
|
|
224
|
+
if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
listen(handler, options = {}) {
|
|
228
|
+
const workers = /* @__PURE__ */ new Map();
|
|
229
|
+
return this.queue.listen(async (message) => {
|
|
230
|
+
while (workers.size >= this.workers) {
|
|
231
|
+
const consumedId = await Promise.any(workers.values());
|
|
232
|
+
workers.delete(consumedId);
|
|
233
|
+
}
|
|
234
|
+
const workerId = crypto.randomUUID();
|
|
235
|
+
const orderingKey = this.#extractOrderingKey(message);
|
|
236
|
+
if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
|
|
237
|
+
this.#pendingMessages.push({
|
|
238
|
+
message,
|
|
239
|
+
orderingKey,
|
|
240
|
+
resolve
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
244
|
+
const promise = this.#work(workerId, handler, message, orderingKey);
|
|
245
|
+
workers.set(workerId, promise);
|
|
246
|
+
}, options);
|
|
247
|
+
}
|
|
248
|
+
async #work(workerId, handler, message, orderingKey) {
|
|
249
|
+
await this.#sleep(0);
|
|
250
|
+
try {
|
|
251
|
+
await handler(message);
|
|
252
|
+
} finally {
|
|
253
|
+
if (orderingKey != null) {
|
|
254
|
+
this.#processingKeys.delete(orderingKey);
|
|
255
|
+
const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
|
|
256
|
+
if (pendingIdx >= 0) this.#pendingMessages.splice(pendingIdx, 1)[0].resolve();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return workerId;
|
|
260
|
+
}
|
|
261
|
+
#sleep(ms) {
|
|
262
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
//#endregion
|
|
11
266
|
//#region src/federation/mq.test.ts
|
|
12
267
|
async function disposeMessageQueue(mq) {
|
|
13
268
|
if (Symbol.asyncDispose in mq) {
|
|
@@ -27,9 +282,6 @@ test("InProcessMessageQueue", async (t) => {
|
|
|
27
282
|
await t.step("nativeRetrial property", () => {
|
|
28
283
|
assertFalse(mq.nativeRetrial);
|
|
29
284
|
});
|
|
30
|
-
await t.step("nativeDeduplication property", () => {
|
|
31
|
-
assertFalse(mq.nativeDeduplication);
|
|
32
|
-
});
|
|
33
285
|
await t.step("getDepth() [empty]", async () => {
|
|
34
286
|
assertEquals(await mq.getDepth(), {
|
|
35
287
|
queued: 0,
|
|
@@ -315,97 +567,6 @@ test("MessageQueue.nativeRetrial", async (t) => {
|
|
|
315
567
|
assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
|
|
316
568
|
});
|
|
317
569
|
});
|
|
318
|
-
test("ParallelMessageQueue inherits nativeDeduplication", () => {
|
|
319
|
-
class NativeDeduplicationQueue {
|
|
320
|
-
nativeDeduplication = true;
|
|
321
|
-
enqueue() {
|
|
322
|
-
return Promise.resolve();
|
|
323
|
-
}
|
|
324
|
-
listen() {
|
|
325
|
-
return Promise.resolve();
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
assert(new ParallelMessageQueue(new NativeDeduplicationQueue(), 5).nativeDeduplication);
|
|
329
|
-
});
|
|
330
|
-
test("ParallelMessageQueue forwards deduplicationKey to the wrapped queue", async () => {
|
|
331
|
-
class RecordingQueue {
|
|
332
|
-
nativeDeduplication = true;
|
|
333
|
-
singles = [];
|
|
334
|
-
batches = [];
|
|
335
|
-
enqueue(_message, options) {
|
|
336
|
-
this.singles.push(options);
|
|
337
|
-
return Promise.resolve();
|
|
338
|
-
}
|
|
339
|
-
enqueueMany(_messages, options) {
|
|
340
|
-
this.batches.push(options);
|
|
341
|
-
return Promise.resolve();
|
|
342
|
-
}
|
|
343
|
-
listen() {
|
|
344
|
-
return Promise.resolve();
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const inner = new RecordingQueue();
|
|
348
|
-
const workers = new ParallelMessageQueue(inner, 5);
|
|
349
|
-
await workers.enqueue({ x: 1 }, { deduplicationKey: "k1" });
|
|
350
|
-
await workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k2" });
|
|
351
|
-
assertEquals(inner.singles[0]?.deduplicationKey, "k1");
|
|
352
|
-
assertEquals(inner.batches[0]?.deduplicationKey, "k2");
|
|
353
|
-
});
|
|
354
|
-
test("ParallelMessageQueue rejects a deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
|
|
355
|
-
class NoBulkQueue {
|
|
356
|
-
nativeDeduplication = true;
|
|
357
|
-
enqueued = [];
|
|
358
|
-
enqueue(message) {
|
|
359
|
-
this.enqueued.push(message);
|
|
360
|
-
return Promise.resolve();
|
|
361
|
-
}
|
|
362
|
-
listen() {
|
|
363
|
-
return Promise.resolve();
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
const inner = new NoBulkQueue();
|
|
367
|
-
const workers = new ParallelMessageQueue(inner, 5);
|
|
368
|
-
await assertRejects(() => workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k" }), TypeError, "enqueueMany");
|
|
369
|
-
assertEquals(inner.enqueued.length, 0);
|
|
370
|
-
});
|
|
371
|
-
test("ParallelMessageQueue falls back to enqueue() for a single deduplicated item when the wrapped queue lacks enqueueMany", async () => {
|
|
372
|
-
class NoBulkQueue {
|
|
373
|
-
nativeDeduplication = true;
|
|
374
|
-
enqueued = [];
|
|
375
|
-
options = [];
|
|
376
|
-
enqueue(message, options) {
|
|
377
|
-
this.enqueued.push(message);
|
|
378
|
-
this.options.push(options);
|
|
379
|
-
return Promise.resolve();
|
|
380
|
-
}
|
|
381
|
-
listen() {
|
|
382
|
-
return Promise.resolve();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
const inner = new NoBulkQueue();
|
|
386
|
-
await new ParallelMessageQueue(inner, 5).enqueueMany([{ x: 1 }], { deduplicationKey: "k" });
|
|
387
|
-
assertEquals(inner.enqueued, [{ x: 1 }]);
|
|
388
|
-
assertEquals(inner.options[0]?.deduplicationKey, "k");
|
|
389
|
-
});
|
|
390
|
-
test("ParallelMessageQueue still fans out a non-deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
|
|
391
|
-
class NoBulkQueue {
|
|
392
|
-
enqueued = [];
|
|
393
|
-
enqueue(message) {
|
|
394
|
-
this.enqueued.push(message);
|
|
395
|
-
return Promise.resolve();
|
|
396
|
-
}
|
|
397
|
-
listen() {
|
|
398
|
-
return Promise.resolve();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const inner = new NoBulkQueue();
|
|
402
|
-
await new ParallelMessageQueue(inner, 5).enqueueMany([
|
|
403
|
-
{ x: 1 },
|
|
404
|
-
{ x: 2 },
|
|
405
|
-
{ x: 3 }
|
|
406
|
-
]);
|
|
407
|
-
assertEquals(inner.enqueued.length, 3);
|
|
408
|
-
});
|
|
409
570
|
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
|
410
571
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
|
|
411
572
|
const packageName = () => "@fedify/denokv";
|
|
@@ -421,9 +582,6 @@ for (const mqName in queues) test({
|
|
|
421
582
|
await t.step("nativeRetrial property inheritance", () => {
|
|
422
583
|
assertEquals(workers.nativeRetrial, mq.nativeRetrial);
|
|
423
584
|
});
|
|
424
|
-
await t.step("nativeDeduplication property inheritance", () => {
|
|
425
|
-
assertEquals(workers.nativeDeduplication, mq.nativeDeduplication);
|
|
426
|
-
});
|
|
427
585
|
await t.step("getDepth() delegation", async () => {
|
|
428
586
|
if (mq.getDepth == null) assertEquals(workers.getDepth, void 0);
|
|
429
587
|
else assertEquals(await workers.getDepth?.(), await mq.getDepth());
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import "../std__assert-
|
|
5
|
-
import { r as assertFalse } from "../assert_rejects-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
7
|
-
import { t as acceptsJsonLd } from "../negotiation-
|
|
4
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
5
|
+
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
6
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
7
|
+
import { t as acceptsJsonLd } from "../negotiation-DDstyBvc.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/negotiation.test.ts
|
|
10
10
|
test("acceptsJsonLd()", () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { l as AssertionError, t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { t as assertNotEquals } from "../assert_not_equals-
|
|
6
|
-
import { t as createExponentialBackoffPolicy } from "../retry-
|
|
4
|
+
import { l as AssertionError, t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
6
|
+
import { t as createExponentialBackoffPolicy } from "../retry-CXg_MBI-.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
//#region src/federation/retry.test.ts
|
|
9
9
|
test("createExponentialBackoffPolicy()", () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { r as assertFalse } from "../assert_rejects-
|
|
7
|
-
import { t as assertThrows } from "../assert_throws-
|
|
8
|
-
import { t as assert } from "../assert-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
+
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
8
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { Router, RouterError, assertPath, isPath } from "@fedify/uri-template";
|
|
11
11
|
import { test } from "@fedify/fixture";
|
|
@@ -2,16 +2,16 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-vrlUxr60.mjs";
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-
|
|
8
|
-
import { t as assertInstanceOf } from "../assert_instance_of-
|
|
9
|
-
import { t as assertNotEquals } from "../assert_not_equals-
|
|
10
|
-
import { t as assert } from "../assert-
|
|
11
|
-
import { l as verifyRequest } from "../http-
|
|
12
|
-
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-
|
|
13
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
14
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
10
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
11
|
+
import { l as verifyRequest } from "../http-L7wqkbZR.mjs";
|
|
12
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
13
|
+
import { t as doesActorOwnKey } from "../owner-BqPUA8Z6.mjs";
|
|
14
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DVtEjoJ6.mjs";
|
|
15
15
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
16
16
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
17
17
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import "../std__assert-
|
|
5
|
-
import { r as assertFalse } from "../assert_rejects-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
7
|
-
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-
|
|
4
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
5
|
+
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
6
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
7
|
+
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-B06FcmVK.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/temporal.test.ts
|
|
10
10
|
test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { r as createRequestContext } from "../context-
|
|
5
|
-
import { t as
|
|
6
|
-
import
|
|
7
|
-
import "../
|
|
8
|
-
import { t as
|
|
9
|
-
import { o as createFederation, s as handleWebFinger } from "../middleware-
|
|
4
|
+
import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
9
|
+
import { o as createFederation, s as handleWebFinger } from "../middleware-RxFBNV2C.mjs";
|
|
10
10
|
import { Image, Link, Person, Tombstone } from "@fedify/vocab";
|
|
11
11
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/webfinger.test.ts
|
|
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
|
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "2.4.0-dev.
|
|
13
|
+
var version = "2.4.0-dev.1528+fea670ad";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
|
|
|
11
11
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
12
12
|
//#region deno.json
|
|
13
13
|
var name = "@fedify/fedify";
|
|
14
|
-
var version = "2.4.0-dev.
|
|
14
|
+
var version = "2.4.0-dev.1528+fea670ad";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sig/accept.ts
|
|
17
17
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-
|
|
7
|
-
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DvClPYaE.mjs";
|
|
6
|
+
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPkZzmGN.mjs";
|
|
7
|
+
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-Ct8zNgGk.mjs";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { CryptographicKey } from "@fedify/vocab";
|
|
10
10
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
|
|
5
|
+
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-DvClPYaE.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { p as recordDocumentCache } from "./metrics-
|
|
4
|
+
import { p as recordDocumentCache } from "./metrics-DvClPYaE.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
6
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/utils/kv-cache.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-EkV7OslM.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-
|
|
3
|
+
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-B0-9u_1F.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { curry } from "es-toolkit";
|
|
6
6
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DvClPYaE.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-Ct8zNgGk.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/federation/metrics.ts
|