@fedify/fedify 2.4.0-dev.1668 → 2.4.0-dev.1740
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/README.md +1 -1
- package/dist/{assert-CJ1KXcvv.mjs → assert-CebeUf0C.mjs} +1 -1
- package/dist/assert_exists-DtzkXC47.mjs +28 -0
- package/dist/assert_false-3pLLLsO4.mjs +23 -0
- package/dist/assert_greater_or_equal-BApOTh1h.mjs +30 -0
- package/dist/{assert_instance_of-Q9KTBnrf.mjs → assert_instance_of-g3WcyYNR.mjs} +1 -1
- package/dist/{assert_not_equals-EPJPoxuf.mjs → assert_not_equals-BN7yDMWe.mjs} +1 -1
- package/dist/assert_rejects-wFbSPn1O.mjs +39 -0
- package/dist/{assert_strict_equals-Ec20AUwa.mjs → assert_strict_equals-Bpjl4Psw.mjs} +1 -1
- package/dist/{assert_throws-NiFfqbnH.mjs → assert_throws-BJ5wuvR2.mjs} +1 -1
- package/dist/{builder-iXZ5jNVg.mjs → builder-Bw6LVKGw.mjs} +5 -3
- package/dist/{circuit-breaker-CBGyz5F7.mjs → circuit-breaker-BT7CiPbz.mjs} +191 -9
- package/dist/circuit-breaker-test-utils-BYIHoliq.mjs +14 -0
- package/dist/{client-CjF5IYQS.mjs → client-CtxvmazV.mjs} +63 -5
- package/dist/{collection-BIhlldqK.mjs → collection-CnnP1UAv.mjs} +1 -1
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/mod.js +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-C05Rgxmu.d.cts → context-B-dsBjZ9.d.cts} +281 -7
- package/dist/{context-Cjnr0ig1.d.ts → context-DrLXudbA.d.ts} +281 -7
- package/dist/{deno-DtHcfB0f.mjs → deno-tRdp8MCl.mjs} +1 -1
- package/dist/{docloader-0vAfF6XW.mjs → docloader-Dg_7gMC7.mjs} +2 -2
- package/dist/{esm-yYQfPhIY.mjs → esm-BHXXx4Wx.mjs} +13 -6
- package/dist/federation/builder.test.mjs +18 -5
- package/dist/federation/circuit-breaker.test.mjs +626 -7
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +14 -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 +37 -28
- package/dist/federation/mod.cjs +18 -540
- package/dist/federation/mod.d.cts +3 -4
- package/dist/federation/mod.d.ts +3 -4
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +32 -5
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +7 -7
- package/dist/federation/send.test.mjs +28 -26
- package/dist/federation/tasks/codec.test.mjs +4 -4
- package/dist/federation/tasks/enqueue.test.mjs +4 -4
- package/dist/federation/tasks/tasks.test.mjs +6 -6
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +74 -12
- package/dist/{middleware-DzIUFRO2.cjs → federation-BJBpt_Am.cjs} +855 -114
- package/dist/{http-BbnOMQoy.js → http-BIxGa6AG.js} +3 -3
- package/dist/{http-DUmWq5Pw.mjs → http-Day1kcpT.mjs} +5 -5
- package/dist/{temporal-polyfill-BCdTHexd.cjs → http-DggG1scN.cjs} +2801 -104
- package/dist/{key-CM7wDnZG.mjs → key-igh0AMsL.mjs} +2 -2
- package/dist/{kv-cache-ZQ22hm44.js → kv-cache-BIAB0HKx.js} +1 -1
- package/dist/{kv-cache-DEXKemJ9.mjs → kv-cache-Bz6aQOOX.mjs} +1 -1
- package/dist/{kv-cache-zmgG1HUp.cjs → kv-cache-C4U_uBqD.cjs} +2 -4
- package/dist/{ld-BttH_-8K.mjs → ld-DnT9sCWa.mjs} +5 -5
- package/dist/metrics-DVKYY6K1.d.cts +36 -0
- package/dist/{metrics-DT-CnD1g.mjs → metrics-DbdNnWIt.mjs} +2 -2
- package/dist/metrics-DoRtI0qU.d.ts +36 -0
- package/dist/{middleware-ChlYS0Af.mjs → middleware-B6GweVcg.mjs} +1 -1
- package/dist/{middleware-D3IAVMcT.js → middleware-CnsPXG0O.js} +241 -40
- package/dist/{middleware-DrroX3aD.mjs → middleware-DPIS4fsB.mjs} +60 -43
- package/dist/{mod-BrpVsSfY.d.cts → mod-CLHkCwLm.d.cts} +3 -3
- package/dist/{mod-B0hW12_O.d.cts → mod-CnGLNoVw.d.cts} +86 -4
- package/dist/{mod-DdONo-ep.d.cts → mod-D-abvu2C.d.cts} +1 -1
- package/dist/{mod-BsCE5Ihq.d.ts → mod-D6O8C7eN.d.ts} +1 -1
- package/dist/{mod-CNef4in0.d.ts → mod-DypxPS9H.d.ts} +3 -3
- package/dist/{mod-COIAjwRS.d.ts → mod-DzRXACM5.d.ts} +86 -4
- package/dist/mod.cjs +25 -25
- package/dist/mod.d.cts +10 -11
- package/dist/mod.d.ts +10 -11
- package/dist/mod.js +8 -8
- package/dist/nodeinfo/client.test.mjs +64 -4
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/otel/mod.cjs +0 -1
- package/dist/otel/mod.d.cts +1 -1
- package/dist/otel/mod.d.ts +1 -1
- package/dist/{outgoing-jsonld-URuqsICz.mjs → outgoing-jsonld-BQSHRLhg.mjs} +2 -2
- package/dist/{owner-DZALmhdl.mjs → owner-B3ef8GfJ.mjs} +2 -2
- package/dist/{proof-CqA-2nfW.js → proof-BBLQXRWw.js} +608 -36
- package/dist/{proof-a60oVJ_4.cjs → proof-Cqk2TcLX.cjs} +616 -39
- package/dist/proof-DVoDZ8d7.mjs +890 -0
- package/dist/{public-audience-Cr5MsnMq.mjs → public-audience--9hx7IGx.mjs} +1 -1
- package/dist/runtime/mod.cjs +1 -1
- package/dist/runtime/mod.js +1 -1
- package/dist/{send-DcwZnQWG.mjs → send-PbBSZ7Qk.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +37 -11
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +9 -7
- package/dist/sig/mod.cjs +3 -2
- package/dist/sig/mod.d.cts +4 -4
- package/dist/sig/mod.d.ts +4 -4
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +965 -15
- package/dist/std__assert-CxFT0MNt.mjs +8 -0
- package/dist/{temporal-Bpxpsl2k.mjs → temporal-DLQIjuTn.mjs} +3 -3
- package/dist/testing/mod.d.mts +10 -0
- package/dist/testing/mod.mjs +2 -2
- package/dist/{testing-CO7ftO8A.mjs → testing-BX0Nicyq.mjs} +2 -2
- package/dist/{transformers-DGwl-hD1.cjs → transformers-BalCrSsr.cjs} +0 -1
- package/dist/{types-DC1pNgJA.js → types-Dtyf8lVj.js} +63 -5
- package/dist/{types-CPym83zc.cjs → types-RXm5YxpC.cjs} +62 -5
- package/dist/utils/docloader.test.mjs +7 -7
- package/dist/utils/kv-cache.test.mjs +1 -1
- 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 +7 -7
- package/skills/fedify/SKILL.md +462 -0
- package/dist/assert_rejects-EgstcQy5.mjs +0 -82
- package/dist/http-BpT5cE6r.cjs +0 -2694
- package/dist/metrics-DN13mCAw.d.cts +0 -294
- package/dist/metrics-v_e0n5GQ.d.ts +0 -294
- package/dist/proof-DiQ0uBal.mjs +0 -316
- package/dist/std__assert-B2NnY9bq.mjs +0 -79
- /package/dist/{accept-8PiolDP7.mjs → accept-CPVqki78.mjs} +0 -0
- /package/dist/{activity-listener-BtTSxZWA.mjs → activity-listener-C-BSbKI7.mjs} +0 -0
- /package/dist/{assert_equals-BV7oLMxm.mjs → assert_equals-CBlRfA-_.mjs} +0 -0
- /package/dist/{client-CAM_bQXx.d.cts → client-D-XP_Ccb.d.cts} +0 -0
- /package/dist/{client-CSddvgWN.d.ts → client-D-XP_Ccb.d.ts} +0 -0
- /package/dist/{codec-BBga-FWI.mjs → codec-peqOdBaE.mjs} +0 -0
- /package/dist/{context-BJXxPElm.mjs → context-Dt36KFEJ.mjs} +0 -0
- /package/dist/{http-VyDTd4G3.d.cts → http-6TI0tI03.d.cts} +0 -0
- /package/dist/{http-lf8Hsd91.d.ts → http-CdrSn2ip.d.ts} +0 -0
- /package/dist/{keycache-_DHqz5z_.mjs → keycache-0Jk78XmB.mjs} +0 -0
- /package/dist/{keys-Dbyd7bhl.mjs → keys-DIJNHW-Y.mjs} +0 -0
- /package/dist/{kv-D6hNiMTK.d.ts → kv-BhNbN8Ed.d.cts} +0 -0
- /package/dist/{kv-gJ8LYbxX.d.cts → kv-BhNbN8Ed.d.ts} +0 -0
- /package/dist/{kv-CXBAok3k.mjs → kv-DCHkaJ9-.mjs} +0 -0
- /package/dist/{mq-Bo7Etgh6.mjs → mq-Dm1Wmtm-.mjs} +0 -0
- /package/dist/{negotiation-RuwrPFqi.mjs → negotiation-CCocWT_N.mjs} +0 -0
- /package/dist/{owner-CnngXDNJ.d.ts → owner-DGSfntI-.d.ts} +0 -0
- /package/dist/{owner-DEvZuyOE.d.cts → owner-r_waTiQj.d.cts} +0 -0
- /package/dist/{retry-DgFqeS5k.mjs → retry-zX5xw5e0.mjs} +0 -0
- /package/dist/{chunk-D5IdezsZ.js → rolldown-runtime-BC-Eo5Mj.js} +0 -0
- /package/dist/{chunk-Czpeue4M.cjs → rolldown-runtime-Dmm3t92W.cjs} +0 -0
- /package/dist/{transformers-DXze6FUB.js → transformers-DAtXl_Kc.js} +0 -0
- /package/dist/{types-CrtdVuDP.mjs → types-DE_LV1JB.mjs} +0 -0
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
3
|
-
import { MeterProvider } from "@opentelemetry/api";
|
|
4
|
-
|
|
5
|
-
//#region src/federation/mq.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Additional options for enqueuing a message in a queue.
|
|
8
|
-
*
|
|
9
|
-
* @since 0.5.0
|
|
10
|
-
*/
|
|
11
|
-
interface MessageQueueEnqueueOptions {
|
|
12
|
-
/**
|
|
13
|
-
* The delay before the message is enqueued. No delay by default.
|
|
14
|
-
*
|
|
15
|
-
* It must not be negative.
|
|
16
|
-
*/
|
|
17
|
-
readonly delay?: Temporal.Duration;
|
|
18
|
-
/**
|
|
19
|
-
* An optional key that ensures messages with the same ordering key are
|
|
20
|
-
* processed sequentially (one at a time). Messages with different ordering
|
|
21
|
-
* keys (or no ordering key) may be processed in parallel.
|
|
22
|
-
*
|
|
23
|
-
* This is useful for ensuring that related messages are processed in order,
|
|
24
|
-
* such as ensuring that a `Delete` activity is processed after a `Create`
|
|
25
|
-
* activity for the same object.
|
|
26
|
-
*
|
|
27
|
-
* @since 2.0.0
|
|
28
|
-
*/
|
|
29
|
-
readonly orderingKey?: string;
|
|
30
|
-
/**
|
|
31
|
-
* An optional key requesting at-most-once enqueue semantics for messages
|
|
32
|
-
* that share it. A backend that declares
|
|
33
|
-
* {@link MessageQueue.nativeDeduplication} `true` owns the check: a message
|
|
34
|
-
* whose `deduplicationKey` was already seen within the backend's
|
|
35
|
-
* deduplication window is dropped instead of enqueued. Backends without
|
|
36
|
-
* native deduplication ignore this field; Fedify performs its own
|
|
37
|
-
* best-effort deduplication before reaching them on the paths that support
|
|
38
|
-
* it.
|
|
39
|
-
*
|
|
40
|
-
* @since 2.4.0
|
|
41
|
-
*/
|
|
42
|
-
readonly deduplicationKey?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Additional options for listening to a message queue.
|
|
46
|
-
*
|
|
47
|
-
* @since 1.0.0
|
|
48
|
-
*/
|
|
49
|
-
interface MessageQueueListenOptions {
|
|
50
|
-
/**
|
|
51
|
-
* The signal to abort listening to the message queue.
|
|
52
|
-
*/
|
|
53
|
-
signal?: AbortSignal;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The number of messages waiting in a message queue.
|
|
57
|
-
*
|
|
58
|
-
* @since 2.3.0
|
|
59
|
-
*/
|
|
60
|
-
interface MessageQueueDepth {
|
|
61
|
-
/**
|
|
62
|
-
* The total number of messages still waiting in the backend queue.
|
|
63
|
-
*
|
|
64
|
-
* This does not include messages that have already been handed to a worker
|
|
65
|
-
* for processing.
|
|
66
|
-
*/
|
|
67
|
-
readonly queued: number;
|
|
68
|
-
/**
|
|
69
|
-
* The number of queued messages eligible for immediate processing.
|
|
70
|
-
*
|
|
71
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
72
|
-
* may omit this field.
|
|
73
|
-
*/
|
|
74
|
-
readonly ready?: number;
|
|
75
|
-
/**
|
|
76
|
-
* The number of queued messages scheduled for later delivery.
|
|
77
|
-
*
|
|
78
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
79
|
-
* may omit this field.
|
|
80
|
-
*/
|
|
81
|
-
readonly delayed?: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* An abstract interface for a message queue.
|
|
85
|
-
*
|
|
86
|
-
* @since 0.5.0
|
|
87
|
-
*/
|
|
88
|
-
interface MessageQueue {
|
|
89
|
-
/**
|
|
90
|
-
* Whether the message queue backend provides native retry mechanisms.
|
|
91
|
-
* When `true`, Fedify will skip its own retry logic and rely on the backend
|
|
92
|
-
* to handle retries. When `false` or omitted, Fedify will handle retries
|
|
93
|
-
* using its own retry policies.
|
|
94
|
-
*
|
|
95
|
-
* @default `false`
|
|
96
|
-
* @since 1.7.0
|
|
97
|
-
*/
|
|
98
|
-
readonly nativeRetrial?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Whether the message queue backend deduplicates messages that share a
|
|
101
|
-
* {@link MessageQueueEnqueueOptions.deduplicationKey} natively. When `true`,
|
|
102
|
-
* Fedify forwards the `deduplicationKey` and relies on the backend to drop
|
|
103
|
-
* duplicates; when `false` or omitted, Fedify applies its own best-effort
|
|
104
|
-
* key–value deduplication on the paths that request it.
|
|
105
|
-
*
|
|
106
|
-
* @default `false`
|
|
107
|
-
* @since 2.4.0
|
|
108
|
-
*/
|
|
109
|
-
readonly nativeDeduplication?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Whether {@link enqueueMany} accepts either every message or no messages.
|
|
112
|
-
* Backends that implement `enqueueMany()` by sending messages individually
|
|
113
|
-
* must set this to `false`, so Fedify does not use that method for a batch
|
|
114
|
-
* governed by one `deduplicationKey`. `true` by default when `enqueueMany`
|
|
115
|
-
* is implemented.
|
|
116
|
-
*
|
|
117
|
-
* @default `true`
|
|
118
|
-
* @since 2.4.0
|
|
119
|
-
*/
|
|
120
|
-
readonly atomicEnqueueMany?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Enqueues a message in the queue.
|
|
123
|
-
* @param message The message to enqueue.
|
|
124
|
-
* @param options Additional options for enqueuing the message.
|
|
125
|
-
*/
|
|
126
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Enqueues multiple messages in the queue. This operation is optional,
|
|
129
|
-
* and may not be supported by all implementations. If not supported,
|
|
130
|
-
* Fedify will invoke {@link enqueue} for each message. An implementation
|
|
131
|
-
* that may accept only part of a batch before rejecting must declare
|
|
132
|
-
* {@link atomicEnqueueMany} `false`.
|
|
133
|
-
*
|
|
134
|
-
* @param messages The messages to enqueue.
|
|
135
|
-
* @param options Additional options for enqueuing the messages.
|
|
136
|
-
*/
|
|
137
|
-
enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Listens for messages in the queue.
|
|
140
|
-
* @param handler The handler for messages in the queue.
|
|
141
|
-
* @param options Additional options for listening to the message queue.
|
|
142
|
-
* @returns A promise that resolves when the listening is done. It never
|
|
143
|
-
* rejects, and is resolved when the signal is aborted. If no
|
|
144
|
-
* signal is provided, it never resolves.
|
|
145
|
-
*/
|
|
146
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* Gets the number of messages waiting in the queue.
|
|
149
|
-
*
|
|
150
|
-
* This operation is optional, and may not be supported by all
|
|
151
|
-
* implementations. The returned counts exclude messages currently being
|
|
152
|
-
* handled by a worker.
|
|
153
|
-
*
|
|
154
|
-
* @since 2.3.0
|
|
155
|
-
*/
|
|
156
|
-
getDepth?(): Promise<MessageQueueDepth>;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Additional options for {@link InProcessMessageQueue}.
|
|
160
|
-
* @since 1.0.0
|
|
161
|
-
*/
|
|
162
|
-
interface InProcessMessageQueueOptions {
|
|
163
|
-
/**
|
|
164
|
-
* The interval to poll for messages in the queue. 5 seconds by default.
|
|
165
|
-
* @default `{ seconds: 5 }`
|
|
166
|
-
*/
|
|
167
|
-
pollInterval?: Temporal.Duration | Temporal.DurationLike;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* A message queue that processes messages in the same process.
|
|
171
|
-
* Do not use this in production as it does neither persist messages nor
|
|
172
|
-
* distribute them across multiple processes.
|
|
173
|
-
*
|
|
174
|
-
* @since 0.5.0
|
|
175
|
-
*/
|
|
176
|
-
declare class InProcessMessageQueue implements MessageQueue {
|
|
177
|
-
#private;
|
|
178
|
-
/**
|
|
179
|
-
* In-process message queue does not provide native retry mechanisms.
|
|
180
|
-
* @since 1.7.0
|
|
181
|
-
*/
|
|
182
|
-
readonly nativeRetrial = false;
|
|
183
|
-
/**
|
|
184
|
-
* In-process message queue does not deduplicate messages natively.
|
|
185
|
-
* @since 2.4.0
|
|
186
|
-
*/
|
|
187
|
-
readonly nativeDeduplication = false;
|
|
188
|
-
/**
|
|
189
|
-
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
|
190
|
-
* @param options Additional options for the in-process message queue.
|
|
191
|
-
*/
|
|
192
|
-
constructor(options?: InProcessMessageQueueOptions);
|
|
193
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
194
|
-
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
195
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
196
|
-
getDepth(): Promise<MessageQueueDepth>;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* A message queue that processes messages in parallel. It takes another
|
|
200
|
-
* {@link MessageQueue}, and processes messages in parallel up to a certain
|
|
201
|
-
* number of workers.
|
|
202
|
-
*
|
|
203
|
-
* Actually, it's rather a decorator than a queue itself.
|
|
204
|
-
*
|
|
205
|
-
* Note that the workers do not run in truly parallel, in the sense that they
|
|
206
|
-
* are not running in separate threads or processes. They are running in the
|
|
207
|
-
* same process, but are scheduled to run in parallel. Hence, this is useful
|
|
208
|
-
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
209
|
-
* workloads.
|
|
210
|
-
*
|
|
211
|
-
* When using `ParallelMessageQueue`, the ordering guarantee is preserved
|
|
212
|
-
* *only if* the underlying queue implementation delivers messages in a wrapper
|
|
213
|
-
* format that includes the `__fedify_ordering_key__` property. Currently,
|
|
214
|
-
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
215
|
-
* For other queue implementations (e.g., `InProcessMessageQueue`,
|
|
216
|
-
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
217
|
-
* `AmqpMessageQueue`), the ordering key cannot be detected by
|
|
218
|
-
* `ParallelMessageQueue`, so ordering guarantees are handled by those
|
|
219
|
-
* implementations directly rather than at the `ParallelMessageQueue` level.
|
|
220
|
-
*
|
|
221
|
-
* Messages with the same ordering key will never be processed concurrently
|
|
222
|
-
* by different workers, ensuring sequential processing within each key.
|
|
223
|
-
* Messages with different ordering keys (or no ordering key) can still be
|
|
224
|
-
* processed in parallel.
|
|
225
|
-
*
|
|
226
|
-
* @since 1.0.0
|
|
227
|
-
*/
|
|
228
|
-
declare class ParallelMessageQueue implements MessageQueue {
|
|
229
|
-
#private;
|
|
230
|
-
readonly queue: MessageQueue;
|
|
231
|
-
readonly workers: number;
|
|
232
|
-
/**
|
|
233
|
-
* Inherits the native retry capability from the wrapped queue.
|
|
234
|
-
* @since 1.7.0
|
|
235
|
-
*/
|
|
236
|
-
readonly nativeRetrial?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Inherits the native deduplication capability from the wrapped queue.
|
|
239
|
-
* @since 2.4.0
|
|
240
|
-
*/
|
|
241
|
-
readonly nativeDeduplication?: boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Inherits the atomic batch capability from the wrapped queue.
|
|
244
|
-
* @since 2.4.0
|
|
245
|
-
*/
|
|
246
|
-
readonly atomicEnqueueMany?: boolean;
|
|
247
|
-
readonly getDepth?: () => Promise<MessageQueueDepth>;
|
|
248
|
-
/**
|
|
249
|
-
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
250
|
-
* number of workers.
|
|
251
|
-
* @param queue The message queue to use under the hood. Note that
|
|
252
|
-
* {@link ParallelMessageQueue} cannot be nested.
|
|
253
|
-
* @param workers The number of workers to process messages in parallel.
|
|
254
|
-
* @throws {TypeError} If the given queue is an instance of
|
|
255
|
-
* {@link ParallelMessageQueue}.
|
|
256
|
-
*/
|
|
257
|
-
constructor(queue: MessageQueue, workers: number);
|
|
258
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
259
|
-
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
260
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/federation/metrics.d.ts
|
|
264
|
-
/**
|
|
265
|
-
* The kind of remote ActivityPub lookup, recorded as
|
|
266
|
-
* `activitypub.lookup.kind` on the public-key lookup and remote document
|
|
267
|
-
* fetch metric families.
|
|
268
|
-
*
|
|
269
|
-
* - `public_key`: a public key lookup performed by `fetchKey` /
|
|
270
|
-
* `fetchKeyDetailed` (always recorded on `activitypub.key.lookup*`).
|
|
271
|
-
* - `actor`: a document fetch whose resolved value is an Actor. The
|
|
272
|
-
* bucket exists in the taxonomy for future actor-aware call sites;
|
|
273
|
-
* today, actor documents fetched through Fedify's generic document
|
|
274
|
-
* loader are still classified as `object` because the kind is decided
|
|
275
|
-
* at the loader boundary, before the response is parsed.
|
|
276
|
-
* - `object`: a generic ActivityPub object fetch through Fedify's
|
|
277
|
-
* document loader. This is the default classification for
|
|
278
|
-
* `documentLoader` invocations that do not match a more specific
|
|
279
|
-
* bucket.
|
|
280
|
-
* - `context`: a JSON-LD `@context` document fetch through Fedify's
|
|
281
|
-
* context loader.
|
|
282
|
-
* - `other`: a fetch that does not fit any of the above classifications.
|
|
283
|
-
* @since 2.3.0
|
|
284
|
-
*/
|
|
285
|
-
type LookupKind = "public_key" | "actor" | "object" | "context" | "other";
|
|
286
|
-
/**
|
|
287
|
-
* The {@link LookupKind} values that can appear on remote document fetch
|
|
288
|
-
* metrics. `public_key` lookups are reported on the
|
|
289
|
-
* `activitypub.key.lookup` metric family instead, so it is excluded here.
|
|
290
|
-
* @since 2.3.0
|
|
291
|
-
*/
|
|
292
|
-
type DocumentFetchKind = Exclude<LookupKind, "public_key">;
|
|
293
|
-
//#endregion
|
|
294
|
-
export { MessageQueueDepth as a, ParallelMessageQueue as c, MessageQueue as i, InProcessMessageQueue as n, MessageQueueEnqueueOptions as o, InProcessMessageQueueOptions as r, MessageQueueListenOptions as s, DocumentFetchKind as t };
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { MeterProvider } from "@opentelemetry/api";
|
|
3
|
-
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
4
|
-
|
|
5
|
-
//#region src/federation/mq.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Additional options for enqueuing a message in a queue.
|
|
8
|
-
*
|
|
9
|
-
* @since 0.5.0
|
|
10
|
-
*/
|
|
11
|
-
interface MessageQueueEnqueueOptions {
|
|
12
|
-
/**
|
|
13
|
-
* The delay before the message is enqueued. No delay by default.
|
|
14
|
-
*
|
|
15
|
-
* It must not be negative.
|
|
16
|
-
*/
|
|
17
|
-
readonly delay?: Temporal.Duration;
|
|
18
|
-
/**
|
|
19
|
-
* An optional key that ensures messages with the same ordering key are
|
|
20
|
-
* processed sequentially (one at a time). Messages with different ordering
|
|
21
|
-
* keys (or no ordering key) may be processed in parallel.
|
|
22
|
-
*
|
|
23
|
-
* This is useful for ensuring that related messages are processed in order,
|
|
24
|
-
* such as ensuring that a `Delete` activity is processed after a `Create`
|
|
25
|
-
* activity for the same object.
|
|
26
|
-
*
|
|
27
|
-
* @since 2.0.0
|
|
28
|
-
*/
|
|
29
|
-
readonly orderingKey?: string;
|
|
30
|
-
/**
|
|
31
|
-
* An optional key requesting at-most-once enqueue semantics for messages
|
|
32
|
-
* that share it. A backend that declares
|
|
33
|
-
* {@link MessageQueue.nativeDeduplication} `true` owns the check: a message
|
|
34
|
-
* whose `deduplicationKey` was already seen within the backend's
|
|
35
|
-
* deduplication window is dropped instead of enqueued. Backends without
|
|
36
|
-
* native deduplication ignore this field; Fedify performs its own
|
|
37
|
-
* best-effort deduplication before reaching them on the paths that support
|
|
38
|
-
* it.
|
|
39
|
-
*
|
|
40
|
-
* @since 2.4.0
|
|
41
|
-
*/
|
|
42
|
-
readonly deduplicationKey?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Additional options for listening to a message queue.
|
|
46
|
-
*
|
|
47
|
-
* @since 1.0.0
|
|
48
|
-
*/
|
|
49
|
-
interface MessageQueueListenOptions {
|
|
50
|
-
/**
|
|
51
|
-
* The signal to abort listening to the message queue.
|
|
52
|
-
*/
|
|
53
|
-
signal?: AbortSignal;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The number of messages waiting in a message queue.
|
|
57
|
-
*
|
|
58
|
-
* @since 2.3.0
|
|
59
|
-
*/
|
|
60
|
-
interface MessageQueueDepth {
|
|
61
|
-
/**
|
|
62
|
-
* The total number of messages still waiting in the backend queue.
|
|
63
|
-
*
|
|
64
|
-
* This does not include messages that have already been handed to a worker
|
|
65
|
-
* for processing.
|
|
66
|
-
*/
|
|
67
|
-
readonly queued: number;
|
|
68
|
-
/**
|
|
69
|
-
* The number of queued messages eligible for immediate processing.
|
|
70
|
-
*
|
|
71
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
72
|
-
* may omit this field.
|
|
73
|
-
*/
|
|
74
|
-
readonly ready?: number;
|
|
75
|
-
/**
|
|
76
|
-
* The number of queued messages scheduled for later delivery.
|
|
77
|
-
*
|
|
78
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
79
|
-
* may omit this field.
|
|
80
|
-
*/
|
|
81
|
-
readonly delayed?: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* An abstract interface for a message queue.
|
|
85
|
-
*
|
|
86
|
-
* @since 0.5.0
|
|
87
|
-
*/
|
|
88
|
-
interface MessageQueue {
|
|
89
|
-
/**
|
|
90
|
-
* Whether the message queue backend provides native retry mechanisms.
|
|
91
|
-
* When `true`, Fedify will skip its own retry logic and rely on the backend
|
|
92
|
-
* to handle retries. When `false` or omitted, Fedify will handle retries
|
|
93
|
-
* using its own retry policies.
|
|
94
|
-
*
|
|
95
|
-
* @default `false`
|
|
96
|
-
* @since 1.7.0
|
|
97
|
-
*/
|
|
98
|
-
readonly nativeRetrial?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Whether the message queue backend deduplicates messages that share a
|
|
101
|
-
* {@link MessageQueueEnqueueOptions.deduplicationKey} natively. When `true`,
|
|
102
|
-
* Fedify forwards the `deduplicationKey` and relies on the backend to drop
|
|
103
|
-
* duplicates; when `false` or omitted, Fedify applies its own best-effort
|
|
104
|
-
* key–value deduplication on the paths that request it.
|
|
105
|
-
*
|
|
106
|
-
* @default `false`
|
|
107
|
-
* @since 2.4.0
|
|
108
|
-
*/
|
|
109
|
-
readonly nativeDeduplication?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Whether {@link enqueueMany} accepts either every message or no messages.
|
|
112
|
-
* Backends that implement `enqueueMany()` by sending messages individually
|
|
113
|
-
* must set this to `false`, so Fedify does not use that method for a batch
|
|
114
|
-
* governed by one `deduplicationKey`. `true` by default when `enqueueMany`
|
|
115
|
-
* is implemented.
|
|
116
|
-
*
|
|
117
|
-
* @default `true`
|
|
118
|
-
* @since 2.4.0
|
|
119
|
-
*/
|
|
120
|
-
readonly atomicEnqueueMany?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Enqueues a message in the queue.
|
|
123
|
-
* @param message The message to enqueue.
|
|
124
|
-
* @param options Additional options for enqueuing the message.
|
|
125
|
-
*/
|
|
126
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Enqueues multiple messages in the queue. This operation is optional,
|
|
129
|
-
* and may not be supported by all implementations. If not supported,
|
|
130
|
-
* Fedify will invoke {@link enqueue} for each message. An implementation
|
|
131
|
-
* that may accept only part of a batch before rejecting must declare
|
|
132
|
-
* {@link atomicEnqueueMany} `false`.
|
|
133
|
-
*
|
|
134
|
-
* @param messages The messages to enqueue.
|
|
135
|
-
* @param options Additional options for enqueuing the messages.
|
|
136
|
-
*/
|
|
137
|
-
enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Listens for messages in the queue.
|
|
140
|
-
* @param handler The handler for messages in the queue.
|
|
141
|
-
* @param options Additional options for listening to the message queue.
|
|
142
|
-
* @returns A promise that resolves when the listening is done. It never
|
|
143
|
-
* rejects, and is resolved when the signal is aborted. If no
|
|
144
|
-
* signal is provided, it never resolves.
|
|
145
|
-
*/
|
|
146
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* Gets the number of messages waiting in the queue.
|
|
149
|
-
*
|
|
150
|
-
* This operation is optional, and may not be supported by all
|
|
151
|
-
* implementations. The returned counts exclude messages currently being
|
|
152
|
-
* handled by a worker.
|
|
153
|
-
*
|
|
154
|
-
* @since 2.3.0
|
|
155
|
-
*/
|
|
156
|
-
getDepth?(): Promise<MessageQueueDepth>;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Additional options for {@link InProcessMessageQueue}.
|
|
160
|
-
* @since 1.0.0
|
|
161
|
-
*/
|
|
162
|
-
interface InProcessMessageQueueOptions {
|
|
163
|
-
/**
|
|
164
|
-
* The interval to poll for messages in the queue. 5 seconds by default.
|
|
165
|
-
* @default `{ seconds: 5 }`
|
|
166
|
-
*/
|
|
167
|
-
pollInterval?: Temporal.Duration | Temporal.DurationLike;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* A message queue that processes messages in the same process.
|
|
171
|
-
* Do not use this in production as it does neither persist messages nor
|
|
172
|
-
* distribute them across multiple processes.
|
|
173
|
-
*
|
|
174
|
-
* @since 0.5.0
|
|
175
|
-
*/
|
|
176
|
-
declare class InProcessMessageQueue implements MessageQueue {
|
|
177
|
-
#private;
|
|
178
|
-
/**
|
|
179
|
-
* In-process message queue does not provide native retry mechanisms.
|
|
180
|
-
* @since 1.7.0
|
|
181
|
-
*/
|
|
182
|
-
readonly nativeRetrial = false;
|
|
183
|
-
/**
|
|
184
|
-
* In-process message queue does not deduplicate messages natively.
|
|
185
|
-
* @since 2.4.0
|
|
186
|
-
*/
|
|
187
|
-
readonly nativeDeduplication = false;
|
|
188
|
-
/**
|
|
189
|
-
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
|
190
|
-
* @param options Additional options for the in-process message queue.
|
|
191
|
-
*/
|
|
192
|
-
constructor(options?: InProcessMessageQueueOptions);
|
|
193
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
194
|
-
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
195
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
196
|
-
getDepth(): Promise<MessageQueueDepth>;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* A message queue that processes messages in parallel. It takes another
|
|
200
|
-
* {@link MessageQueue}, and processes messages in parallel up to a certain
|
|
201
|
-
* number of workers.
|
|
202
|
-
*
|
|
203
|
-
* Actually, it's rather a decorator than a queue itself.
|
|
204
|
-
*
|
|
205
|
-
* Note that the workers do not run in truly parallel, in the sense that they
|
|
206
|
-
* are not running in separate threads or processes. They are running in the
|
|
207
|
-
* same process, but are scheduled to run in parallel. Hence, this is useful
|
|
208
|
-
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
209
|
-
* workloads.
|
|
210
|
-
*
|
|
211
|
-
* When using `ParallelMessageQueue`, the ordering guarantee is preserved
|
|
212
|
-
* *only if* the underlying queue implementation delivers messages in a wrapper
|
|
213
|
-
* format that includes the `__fedify_ordering_key__` property. Currently,
|
|
214
|
-
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
215
|
-
* For other queue implementations (e.g., `InProcessMessageQueue`,
|
|
216
|
-
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
217
|
-
* `AmqpMessageQueue`), the ordering key cannot be detected by
|
|
218
|
-
* `ParallelMessageQueue`, so ordering guarantees are handled by those
|
|
219
|
-
* implementations directly rather than at the `ParallelMessageQueue` level.
|
|
220
|
-
*
|
|
221
|
-
* Messages with the same ordering key will never be processed concurrently
|
|
222
|
-
* by different workers, ensuring sequential processing within each key.
|
|
223
|
-
* Messages with different ordering keys (or no ordering key) can still be
|
|
224
|
-
* processed in parallel.
|
|
225
|
-
*
|
|
226
|
-
* @since 1.0.0
|
|
227
|
-
*/
|
|
228
|
-
declare class ParallelMessageQueue implements MessageQueue {
|
|
229
|
-
#private;
|
|
230
|
-
readonly queue: MessageQueue;
|
|
231
|
-
readonly workers: number;
|
|
232
|
-
/**
|
|
233
|
-
* Inherits the native retry capability from the wrapped queue.
|
|
234
|
-
* @since 1.7.0
|
|
235
|
-
*/
|
|
236
|
-
readonly nativeRetrial?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Inherits the native deduplication capability from the wrapped queue.
|
|
239
|
-
* @since 2.4.0
|
|
240
|
-
*/
|
|
241
|
-
readonly nativeDeduplication?: boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Inherits the atomic batch capability from the wrapped queue.
|
|
244
|
-
* @since 2.4.0
|
|
245
|
-
*/
|
|
246
|
-
readonly atomicEnqueueMany?: boolean;
|
|
247
|
-
readonly getDepth?: () => Promise<MessageQueueDepth>;
|
|
248
|
-
/**
|
|
249
|
-
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
250
|
-
* number of workers.
|
|
251
|
-
* @param queue The message queue to use under the hood. Note that
|
|
252
|
-
* {@link ParallelMessageQueue} cannot be nested.
|
|
253
|
-
* @param workers The number of workers to process messages in parallel.
|
|
254
|
-
* @throws {TypeError} If the given queue is an instance of
|
|
255
|
-
* {@link ParallelMessageQueue}.
|
|
256
|
-
*/
|
|
257
|
-
constructor(queue: MessageQueue, workers: number);
|
|
258
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
259
|
-
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
260
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/federation/metrics.d.ts
|
|
264
|
-
/**
|
|
265
|
-
* The kind of remote ActivityPub lookup, recorded as
|
|
266
|
-
* `activitypub.lookup.kind` on the public-key lookup and remote document
|
|
267
|
-
* fetch metric families.
|
|
268
|
-
*
|
|
269
|
-
* - `public_key`: a public key lookup performed by `fetchKey` /
|
|
270
|
-
* `fetchKeyDetailed` (always recorded on `activitypub.key.lookup*`).
|
|
271
|
-
* - `actor`: a document fetch whose resolved value is an Actor. The
|
|
272
|
-
* bucket exists in the taxonomy for future actor-aware call sites;
|
|
273
|
-
* today, actor documents fetched through Fedify's generic document
|
|
274
|
-
* loader are still classified as `object` because the kind is decided
|
|
275
|
-
* at the loader boundary, before the response is parsed.
|
|
276
|
-
* - `object`: a generic ActivityPub object fetch through Fedify's
|
|
277
|
-
* document loader. This is the default classification for
|
|
278
|
-
* `documentLoader` invocations that do not match a more specific
|
|
279
|
-
* bucket.
|
|
280
|
-
* - `context`: a JSON-LD `@context` document fetch through Fedify's
|
|
281
|
-
* context loader.
|
|
282
|
-
* - `other`: a fetch that does not fit any of the above classifications.
|
|
283
|
-
* @since 2.3.0
|
|
284
|
-
*/
|
|
285
|
-
type LookupKind = "public_key" | "actor" | "object" | "context" | "other";
|
|
286
|
-
/**
|
|
287
|
-
* The {@link LookupKind} values that can appear on remote document fetch
|
|
288
|
-
* metrics. `public_key` lookups are reported on the
|
|
289
|
-
* `activitypub.key.lookup` metric family instead, so it is excluded here.
|
|
290
|
-
* @since 2.3.0
|
|
291
|
-
*/
|
|
292
|
-
type DocumentFetchKind = Exclude<LookupKind, "public_key">;
|
|
293
|
-
//#endregion
|
|
294
|
-
export { MessageQueueDepth as a, ParallelMessageQueue as c, MessageQueue as i, InProcessMessageQueue as n, MessageQueueEnqueueOptions as o, InProcessMessageQueueOptions as r, MessageQueueListenOptions as s, DocumentFetchKind as t };
|