@fedify/fedify 0.12.0-dev.263 → 0.12.0-dev.265

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md CHANGED
@@ -8,6 +8,29 @@ Version 0.12.0
8
8
 
9
9
  To be released.
10
10
 
11
+ - Incoming activities are now queued before being dispatched to the inbox
12
+ listener if the `queue` option is provided to the `createFederation()`
13
+ function. [[#70]]
14
+
15
+ - The type of `InboxListener` callback type's first parameter became
16
+ `Context` (was `RequestContext`).
17
+ - The type of `InboxErrorHandler` callback type's first parameter became
18
+ `Context` (was `RequestContext`).
19
+ - The type of `SharedInboxKeyDispatcher` callback type's first parameter
20
+ became `Context` (was `RequestContext`).
21
+
22
+ - Implemented fully customizable retry policy for failed tasks in the task
23
+ queue. By default, the task queue retries the failed tasks with
24
+ an exponential backoff policy with decorrelated jitter.
25
+
26
+ - Added `outboxRetryPolicy` option to `CreateFederationOptions` interface.
27
+ - Added `inboxRetryPolicy` option to `CreateFederationOptions` interface.
28
+ [[#70]]
29
+ - Added `RetryPolicy` callback type.
30
+ - Added `RetryContext` interface.
31
+ - Added `createExponentialBackoffPolicy()` function.
32
+ - Added `CreateExponentialBackoffPolicyOptions` interface.
33
+
11
34
  - Added `ChatMessage` class to Activity Vocabulary API. [[#85]]
12
35
 
13
36
  - Improved multitenancy (virtual hosting) support. [[#66]]
@@ -18,7 +41,18 @@ To be released.
18
41
  - The type of `ActorKeyPairsDispatcher<TContextData>`'s first parameter
19
42
  became `Context` (was `TContextData`).
20
43
 
44
+ - Deprecated `Federation.sendActivity()` method.
45
+
46
+ - The last parameter of `Federation.sendActivity()` method is no longer
47
+ optional. Also, it now takes the required `contextData` option.
48
+
49
+ - Added more log messages using the [LogTape] library. Currently the below
50
+ logger categories are used:
51
+
52
+ - `["fedify", "federation", "queue"]`
53
+
21
54
  [#66]: https://github.com/dahlia/fedify/issues/66
55
+ [#70]: https://github.com/dahlia/fedify/issues/70
22
56
  [#85]: https://github.com/dahlia/fedify/issues/85
23
57
 
24
58
 
@@ -166,7 +166,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
166
166
  }
167
167
  return result;
168
168
  }
169
- export async function handleInbox(request, { handle, context, kv, kvPrefix, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, }) {
169
+ export async function handleInbox(request, { handle, context, kv, kvPrefix, queue, actorDispatcher, inboxListenerDispatcher, inboxErrorHandler, onNotFound, signatureTimeWindow, }) {
170
170
  const logger = getLogger(["fedify", "federation", "inbox"]);
171
171
  if (actorDispatcher == null) {
172
172
  logger.error("Actor dispatcher is not set.", { handle });
@@ -185,7 +185,12 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
185
185
  }
186
186
  catch (error) {
187
187
  logger.error("Failed to parse JSON:\n{error}", { handle, error });
188
- await inboxErrorHandler?.(context, error);
188
+ try {
189
+ await inboxErrorHandler?.(context, error);
190
+ }
191
+ catch (error) {
192
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", { error, activity: json });
193
+ }
189
194
  return new Response("Invalid JSON.", {
190
195
  status: 400,
191
196
  headers: { "Content-Type": "text/plain; charset=utf-8" },
@@ -197,7 +202,12 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
197
202
  }
198
203
  catch (error) {
199
204
  logger.error("Failed to parse activity:\n{error}", { handle, json, error });
200
- await inboxErrorHandler?.(context, error);
205
+ try {
206
+ await inboxErrorHandler?.(context, error);
207
+ }
208
+ catch (error) {
209
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", { error, activity: json });
210
+ }
201
211
  return new Response("Invalid activity.", {
202
212
  status: 400,
203
213
  headers: { "Content-Type": "text/plain; charset=utf-8" },
@@ -256,29 +266,39 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
256
266
  });
257
267
  return response;
258
268
  }
259
- // deno-lint-ignore no-explicit-any
260
- let cls = activity
261
- // deno-lint-ignore no-explicit-any
262
- .constructor;
263
- while (true) {
264
- if (inboxListeners.has(cls))
265
- break;
266
- if (cls === Activity) {
267
- logger.error("Unsupported activity type:\n{activity}", { activity: json });
268
- return new Response("", {
269
- status: 202,
270
- headers: { "Content-Type": "text/plain; charset=utf-8" },
271
- });
272
- }
273
- cls = globalThis.Object.getPrototypeOf(cls);
269
+ if (queue != null) {
270
+ await queue.enqueue({
271
+ type: "inbox",
272
+ baseUrl: request.url,
273
+ activity: json,
274
+ handle,
275
+ attempt: 0,
276
+ started: new Date().toISOString(),
277
+ });
278
+ return new Response("Activity is enqueued.", {
279
+ status: 202,
280
+ headers: { "Content-Type": "text/plain; charset=utf-8" },
281
+ });
282
+ }
283
+ const listener = inboxListenerDispatcher(activity);
284
+ if (listener == null) {
285
+ logger.error("Unsupported activity type:\n{activity}", { activity: json });
286
+ return new Response("", {
287
+ status: 202,
288
+ headers: { "Content-Type": "text/plain; charset=utf-8" },
289
+ });
274
290
  }
275
- const listener = inboxListeners.get(cls);
276
291
  try {
277
292
  await listener(context, activity);
278
293
  }
279
294
  catch (error) {
280
- logger.error("Failed to process the activity:\n{error}", { error, activity: json });
281
- await inboxErrorHandler?.(context, error);
295
+ try {
296
+ await inboxErrorHandler?.(context, error);
297
+ }
298
+ catch (error) {
299
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", { error, activityId: activity.id?.href, activity: json });
300
+ }
301
+ logger.error("Failed to process the incoming activity {activityId}:\n{error}", { error, activityId: activity.id?.href, activity: json });
282
302
  return new Response("Internal server error.", {
283
303
  status: 500,
284
304
  headers: { "Content-Type": "text/plain; charset=utf-8" },
@@ -9,6 +9,7 @@ import { Activity, CryptographicKey, Multikey, } from "../vocab/vocab.js";
9
9
  import { handleWebFinger } from "../webfinger/handler.js";
10
10
  import { buildCollectionSynchronizationHeader } from "./collection.js";
11
11
  import { handleActor, handleCollection, handleInbox, handleObject, } from "./handler.js";
12
+ import { createExponentialBackoffPolicy } from "./retry.js";
12
13
  import { Router, RouterError } from "./router.js";
13
14
  import { extractInboxes, sendActivity } from "./send.js";
14
15
  const invokedByCreateFederation = Symbol("invokedByCreateFederation");
@@ -25,6 +26,7 @@ export function createFederation(options) {
25
26
  [invokedByCreateFederation]: true,
26
27
  });
27
28
  }
29
+ const invokedByContext = Symbol("invokedByContext");
28
30
  /**
29
31
  * An object that registers federation-related business logic and dispatches
30
32
  * requests to the appropriate handlers.
@@ -59,13 +61,15 @@ export class Federation {
59
61
  #treatHttps;
60
62
  #onOutboxError;
61
63
  #signatureTimeWindow;
62
- #backoffSchedule;
64
+ #outboxRetryPolicy;
65
+ #inboxRetryPolicy;
63
66
  /**
64
67
  * Create a new {@link Federation} instance.
65
68
  * @param parameters Parameters for initializing the instance.
66
69
  * @deprecated Use {@link createFederation} method instead.
67
70
  */
68
- constructor(options) {
71
+ constructor(parameters) {
72
+ const options = parameters;
69
73
  const logger = getLogger(["fedify", "federation"]);
70
74
  // @ts-ignore: This is a private symbol.
71
75
  if (!options[invokedByCreateFederation]) {
@@ -97,37 +101,42 @@ export class Federation {
97
101
  options.authenticatedDocumentLoaderFactory ??
98
102
  getAuthenticatedDocumentLoader;
99
103
  this.#onOutboxError = options.onOutboxError;
100
- this.#treatHttps = options.treatHttps ?? false;
101
- if (options.treatHttps) {
104
+ this.#treatHttps = parameters.treatHttps ?? false;
105
+ if (parameters.treatHttps) {
102
106
  logger.warn("The treatHttps option is deprecated and will be removed in " +
103
107
  "a future release. Instead, use the x-forwarded-fetch library" +
104
108
  " to recognize the X-Forwarded-Host and X-Forwarded-Proto " +
105
109
  "headers. See also: <https://github.com/dahlia/x-forwarded-fetch>.");
106
110
  }
107
111
  this.#signatureTimeWindow = options.signatureTimeWindow ?? { minutes: 1 };
108
- this.#backoffSchedule = options.backoffSchedule ?? [
109
- 3000,
110
- 15000,
111
- 60000,
112
- 15 * 60000,
113
- 60 * 60000,
114
- ].map((ms) => dntShim.Temporal.Duration.from({ milliseconds: ms }));
112
+ this.#outboxRetryPolicy = options.outboxRetryPolicy ??
113
+ createExponentialBackoffPolicy();
114
+ this.#inboxRetryPolicy = options.inboxRetryPolicy ??
115
+ createExponentialBackoffPolicy();
115
116
  }
116
- #startQueue() {
117
+ #startQueue(ctxData) {
117
118
  if (this.#queue != null && !this.#queueStarted) {
118
- const logger = getLogger(["fedify", "federation", "outbox"]);
119
- logger.debug("Starting an outbox queue.");
120
- this.#queue?.listen(this.#listenQueue.bind(this));
119
+ const logger = getLogger(["fedify", "federation", "queue"]);
120
+ logger.debug("Starting a task queue.");
121
+ this.#queue?.listen((msg) => this.#listenQueue(ctxData, msg));
121
122
  this.#queueStarted = true;
122
123
  }
123
124
  }
124
- async #listenQueue(message) {
125
+ async #listenQueue(ctxData, message) {
126
+ if (message.type === "outbox") {
127
+ await this.#listenOutboxMessage(ctxData, message);
128
+ }
129
+ else if (message.type === "inbox") {
130
+ await this.#listenInboxMessage(ctxData, message);
131
+ }
132
+ }
133
+ async #listenOutboxMessage(_, message) {
125
134
  const logger = getLogger(["fedify", "federation", "outbox"]);
126
135
  const logData = {
127
136
  keyIds: message.keys.map((pair) => pair.keyId),
128
137
  inbox: message.inbox,
129
138
  activity: message.activity,
130
- trial: message.trial,
139
+ attempt: message.attempt,
131
140
  headers: message.headers,
132
141
  };
133
142
  let activity = null;
@@ -167,22 +176,120 @@ export class Federation {
167
176
  catch (error) {
168
177
  logger.error("An unexpected error occurred in onError handler:\n{error}", { ...logData, error, activityId: activity?.id?.href });
169
178
  }
170
- if (message.trial < this.#backoffSchedule.length) {
171
- logger.error("Failed to send activity {activityId} to {inbox} (trial #{trial})" +
172
- "; retry...:\n{error}", { ...logData, error, activityId: activity?.id?.href });
179
+ const delay = this.#outboxRetryPolicy({
180
+ elapsedTime: dntShim.Temporal.Instant.from(message.started).until(dntShim.Temporal.Now.instant()),
181
+ attempts: message.attempt,
182
+ });
183
+ if (delay != null) {
184
+ logger.error("Failed to send activity {activityId} to {inbox} (attempt " +
185
+ "#{attempt}); retry...:\n{error}", { ...logData, error, activityId: activity?.id?.href });
173
186
  this.#queue?.enqueue({
174
187
  ...message,
175
- trial: message.trial + 1,
176
- }, { delay: this.#backoffSchedule[message.trial] });
188
+ attempt: message.attempt + 1,
189
+ }, {
190
+ delay: dntShim.Temporal.Duration.compare(delay, { seconds: 0 }) < 0
191
+ ? dntShim.Temporal.Duration.from({ seconds: 0 })
192
+ : delay,
193
+ });
177
194
  }
178
195
  else {
179
- logger.error("Failed to send activity {activityId} to {inbox} after {trial} " +
180
- "trials; giving up:\n{error}", { ...logData, error, activityId: activity?.id?.href });
196
+ logger.error("Failed to send activity {activityId} to {inbox} after {attempt} " +
197
+ "attempts; giving up:\n{error}", { ...logData, error, activityId: activity?.id?.href });
181
198
  }
182
199
  return;
183
200
  }
184
201
  logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData, activityId: activity?.id?.href });
185
202
  }
203
+ async #listenInboxMessage(ctxData, message) {
204
+ const logger = getLogger(["fedify", "federation", "inbox"]);
205
+ const baseUrl = new URL(message.baseUrl);
206
+ let context = this.#createContext(baseUrl, ctxData);
207
+ if (message.handle) {
208
+ context = this.#createContext(baseUrl, ctxData, {
209
+ documentLoader: await context.getDocumentLoader({
210
+ handle: message.handle,
211
+ }),
212
+ });
213
+ }
214
+ else if (this.#sharedInboxKeyDispatcher != null) {
215
+ const identity = await this.#sharedInboxKeyDispatcher(context);
216
+ if (identity != null) {
217
+ context = this.#createContext(baseUrl, ctxData, {
218
+ documentLoader: "handle" in identity
219
+ ? await context.getDocumentLoader(identity)
220
+ : context.getDocumentLoader(identity),
221
+ });
222
+ }
223
+ }
224
+ const activity = await Activity.fromJsonLd(message.activity, context);
225
+ const cacheKey = activity.id == null ? null : [
226
+ ...this.#kvPrefixes.activityIdempotence,
227
+ activity.id.href,
228
+ ];
229
+ if (cacheKey != null) {
230
+ const cached = await this.#kv.get(cacheKey);
231
+ if (cached === true) {
232
+ logger.debug("Activity {activityId} has already been processed.", {
233
+ activityId: activity.id?.href,
234
+ activity: message.activity,
235
+ });
236
+ return;
237
+ }
238
+ }
239
+ const listener = this.#dispatchInboxListener(activity);
240
+ if (listener == null) {
241
+ logger.error("Unsupported activity type:\n{activity}", { activity: message.activity, trial: message.attempt });
242
+ return;
243
+ }
244
+ try {
245
+ await listener(context, activity);
246
+ }
247
+ catch (error) {
248
+ try {
249
+ await this.#inboxErrorHandler?.(context, error);
250
+ }
251
+ catch (error) {
252
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
253
+ error,
254
+ trial: message.attempt,
255
+ activityId: activity.id?.href,
256
+ activity: message.activity,
257
+ });
258
+ }
259
+ const delay = this.#inboxRetryPolicy({
260
+ elapsedTime: dntShim.Temporal.Instant.from(message.started).until(dntShim.Temporal.Now.instant()),
261
+ attempts: message.attempt,
262
+ });
263
+ if (delay != null) {
264
+ logger.error("Failed to process the incoming activity {activityId} (attempt " +
265
+ "#{attempt}); retry...:\n{error}", {
266
+ error,
267
+ attempt: message.attempt,
268
+ activityId: activity.id?.href,
269
+ activity: message.activity,
270
+ });
271
+ this.#queue?.enqueue({
272
+ ...message,
273
+ attempt: message.attempt + 1,
274
+ }, {
275
+ delay: dntShim.Temporal.Duration.compare(delay, { seconds: 0 }) < 0
276
+ ? dntShim.Temporal.Duration.from({ seconds: 0 })
277
+ : delay,
278
+ });
279
+ }
280
+ else {
281
+ logger.error("Failed to process the incoming activity {activityId} after " +
282
+ "{trial} attempts; giving up:\n{error}", { error, activityId: activity.id?.href, activity: message.activity });
283
+ }
284
+ return;
285
+ }
286
+ if (cacheKey != null) {
287
+ await this.#kv.set(cacheKey, true, {
288
+ ttl: dntShim.Temporal.Duration.from({ days: 1 }),
289
+ });
290
+ }
291
+ logger.info("Activity {activityId} has been processed.", { activityId: activity.id?.href, activity: message.activity });
292
+ }
186
293
  createContext(urlOrRequest, contextData) {
187
294
  return urlOrRequest instanceof Request
188
295
  ? this.#createContext(urlOrRequest, contextData)
@@ -849,6 +956,25 @@ export class Federation {
849
956
  };
850
957
  return setters;
851
958
  }
959
+ #dispatchInboxListener(activity) {
960
+ // deno-lint-ignore no-explicit-any
961
+ let cls = activity
962
+ // deno-lint-ignore no-explicit-any
963
+ .constructor;
964
+ const inboxListeners = this.#inboxListeners;
965
+ if (inboxListeners == null) {
966
+ return null;
967
+ }
968
+ while (true) {
969
+ if (inboxListeners.has(cls))
970
+ break;
971
+ if (cls === Activity)
972
+ return null;
973
+ cls = globalThis.Object.getPrototypeOf(cls);
974
+ }
975
+ const listener = inboxListeners.get(cls);
976
+ return listener;
977
+ }
852
978
  /**
853
979
  * Sends an activity to recipients' inboxes. You would typically use
854
980
  * {@link Context.sendActivity} instead of this method.
@@ -858,9 +984,15 @@ export class Federation {
858
984
  * @param activity The activity to send.
859
985
  * @param options Options for sending the activity.
860
986
  * @throws {TypeError} If the activity to send does not have an actor.
987
+ * @deprecated Use {@link Context.sendActivity} instead.
861
988
  */
862
- async sendActivity(keys, recipients, activity, { preferSharedInbox, immediate, excludeBaseUris, collectionSync } = {}) {
989
+ async sendActivity(keys, recipients, activity, options) {
863
990
  const logger = getLogger(["fedify", "federation", "outbox"]);
991
+ if (!(invokedByContext in options) || !options[invokedByContext]) {
992
+ logger.warn("The Federation.sendActivity() method is deprecated. Use " +
993
+ "Context.sendActivity() instead.");
994
+ }
995
+ const { preferSharedInbox, immediate, excludeBaseUris, collectionSync, contextData, } = options;
864
996
  if (keys.length < 1) {
865
997
  throw new TypeError("The sender's keys must not be empty.");
866
998
  }
@@ -871,7 +1003,7 @@ export class Federation {
871
1003
  logger.error("Activity {activityId} to send does not have an actor.", { activity, activityId: activity?.id?.href });
872
1004
  throw new TypeError("The activity to send must have at least one actor property.");
873
1005
  }
874
- this.#startQueue();
1006
+ this.#startQueue(contextData);
875
1007
  if (activity.id == null) {
876
1008
  activity = activity.clone({
877
1009
  id: new URL(`urn:uuid:${dntShim.crypto.randomUUID()}`),
@@ -925,7 +1057,8 @@ export class Federation {
925
1057
  keys: keyJwkPairs,
926
1058
  activity: activityJson,
927
1059
  inbox,
928
- trial: 0,
1060
+ started: new Date().toISOString(),
1061
+ attempt: 0,
929
1062
  headers: collectionSync == null ? {} : {
930
1063
  "Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox]),
931
1064
  },
@@ -1067,7 +1200,7 @@ export class Federation {
1067
1200
  kv: this.#kv,
1068
1201
  kvPrefix: this.#kvPrefixes.activityIdempotence,
1069
1202
  actorDispatcher: this.#actorCallbacks?.dispatcher,
1070
- inboxListeners: this.#inboxListeners ?? new Map(),
1203
+ inboxListenerDispatcher: this.#dispatchInboxListener.bind(this),
1071
1204
  inboxErrorHandler: this.#inboxErrorHandler,
1072
1205
  onNotFound,
1073
1206
  signatureTimeWindow: this.#signatureTimeWindow,
@@ -1451,7 +1584,12 @@ class ContextImpl {
1451
1584
  else {
1452
1585
  keys = [sender];
1453
1586
  }
1454
- const opts = { ...options };
1587
+ const opts = {
1588
+ contextData: this.data,
1589
+ ...options,
1590
+ // @ts-ignore: This is a private symbol
1591
+ [invokedByContext]: true,
1592
+ };
1455
1593
  let expandedRecipients;
1456
1594
  if (Array.isArray(recipients)) {
1457
1595
  expandedRecipients = recipients;
@@ -10,4 +10,5 @@ export { respondWithObject, respondWithObjectIfAcceptable, } from "./handler.js"
10
10
  export * from "./kv.js";
11
11
  export * from "./middleware.js";
12
12
  export * from "./mq.js";
13
+ export * from "./retry.js";
13
14
  export * from "./router.js";
@@ -13,7 +13,7 @@ export class InProcessMessageQueue {
13
13
  enqueue(message, options) {
14
14
  const delay = options?.delay == null
15
15
  ? 0
16
- : options.delay.total("millisecond");
16
+ : Math.max(options.delay.total("millisecond"), 0);
17
17
  setTimeout(() => {
18
18
  for (const handler of this.#handlers)
19
19
  handler(message);
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The context passed to a {@link RetryPolicy} callback.
3
+ * @since 0.12.0
4
+ */
5
+ import * as dntShim from "../_dnt.shims.js";
6
+ /**
7
+ * Creates an exponential backoff retry policy. The delay between retries
8
+ * starts at the `initialDelay` and is multiplied by the `factor` for each
9
+ * subsequent retry, up to the `maxDelay`. The policy will give up after
10
+ * `maxAttempts` attempts. The actual delay is randomized to avoid
11
+ * synchronization (jitter).
12
+ * @param options The options for the policy.
13
+ * @returns The retry policy.
14
+ * @since 0.12.0
15
+ */
16
+ export function createExponentialBackoffPolicy(options = {}) {
17
+ const initialDelay = dntShim.Temporal.Duration.from(options.initialDelay ?? { seconds: 1 });
18
+ const maxDelay = dntShim.Temporal.Duration.from(options.maxDelay ?? { hours: 12 });
19
+ const maxAttempts = options.maxAttempts ?? 10;
20
+ const factor = options.factor ?? 2;
21
+ const jitter = options.jitter ?? true;
22
+ return ({ attempts }) => {
23
+ if (attempts >= maxAttempts)
24
+ return null;
25
+ let milliseconds = initialDelay.total("millisecond");
26
+ milliseconds *= factor ** attempts;
27
+ if (jitter) {
28
+ milliseconds *= 1 + Math.random();
29
+ milliseconds = Math.round(milliseconds);
30
+ }
31
+ const delay = dntShim.Temporal.Duration.from({ milliseconds });
32
+ return dntShim.Temporal.Duration.compare(delay, maxDelay) > 0 ? maxDelay : delay;
33
+ };
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.12.0-dev.263+8d28f99f",
3
+ "version": "0.12.0-dev.265+cb851932",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -73,25 +73,25 @@ export type CollectionCursor<TContextData, TFilter> = (context: RequestContext<T
73
73
  * @typeParam TContextData The context data to pass to the {@link Context}.
74
74
  * @typeParam TActivity The type of activity to listen for.
75
75
  */
76
- export type InboxListener<TContextData, TActivity extends Activity> = (context: RequestContext<TContextData>, activity: TActivity) => void | Promise<void>;
76
+ export type InboxListener<TContextData, TActivity extends Activity> = (context: Context<TContextData>, activity: TActivity) => void | Promise<void>;
77
77
  /**
78
78
  * A callback that handles errors in an inbox.
79
79
  *
80
80
  * @typeParam TContextData The context data to pass to the {@link Context}.
81
81
  */
82
- export type InboxErrorHandler<TContextData> = (context: RequestContext<TContextData>, error: Error) => void | Promise<void>;
82
+ export type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
83
83
  /**
84
84
  * A callback that dispatches the key pair for the authenticated document loader
85
85
  * of the {@link Context} passed to the shared inbox listener.
86
86
  *
87
87
  * @typeParam TContextData The context data to pass to the {@link Context}.
88
- * @param context The request context.
88
+ * @param context The context.
89
89
  * @returns The handle of the actor or the key pair for the authenticated
90
90
  * document loader of the {@link Context} passed to the shared inbox
91
91
  * listener. If `null` is returned, the request is not authorized.
92
92
  * @since 0.11.0
93
93
  */
94
- export type SharedInboxKeyDispatcher<TContextData> = (context: RequestContext<TContextData>) => SenderKeyPair | {
94
+ export type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
95
95
  handle: string;
96
96
  } | null | Promise<SenderKeyPair | {
97
97
  handle: string;
@@ -1 +1 @@
1
- {"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/federation/callback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,YAAY,IAAI,CAC7C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,KAClC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAElC;;;;;;;;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AC,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAAG,IAAI,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,CAAC,YAAY,IAAI,CAC7C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,EAAE,MAAM,SAAS,MAAM,IAAI,CAC1E,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAClC,cAAc,EAAE,KAAK,GAAG,IAAI,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -7,6 +7,7 @@ import { Activity, Link, Object } from "../vocab/vocab.js";
7
7
  import type { ActorDispatcher, AuthorizePredicate, CollectionCounter, CollectionCursor, CollectionDispatcher, InboxErrorHandler, InboxListener, ObjectAuthorizePredicate, ObjectDispatcher } from "./callback.js";
8
8
  import type { RequestContext } from "./context.js";
9
9
  import type { KvKey, KvStore } from "./kv.js";
10
+ import type { MessageQueue } from "./mq.js";
10
11
  export declare function acceptsJsonLd(request: Request): boolean;
11
12
  export interface ActorHandlerParameters<TContextData> {
12
13
  handle: string;
@@ -70,13 +71,14 @@ export interface InboxHandlerParameters<TContextData> {
70
71
  context: RequestContext<TContextData>;
71
72
  kv: KvStore;
72
73
  kvPrefix: KvKey;
74
+ queue?: MessageQueue;
73
75
  actorDispatcher?: ActorDispatcher<TContextData>;
74
- inboxListeners: Map<new (...args: unknown[]) => Activity, InboxListener<TContextData, Activity>>;
76
+ inboxListenerDispatcher: (activity: Activity) => InboxListener<TContextData, Activity> | null;
75
77
  inboxErrorHandler?: InboxErrorHandler<TContextData>;
76
78
  onNotFound(request: Request): Response | Promise<Response>;
77
79
  signatureTimeWindow: dntShim.Temporal.DurationLike;
78
80
  }
79
- export declare function handleInbox<TContextData>(request: Request, { handle, context, kv, kvPrefix, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, }: InboxHandlerParameters<TContextData>): Promise<Response>;
81
+ export declare function handleInbox<TContextData>(request: Request, { handle, context, kv, kvPrefix, queue, actorDispatcher, inboxListenerDispatcher, inboxErrorHandler, onNotFound, signatureTimeWindow, }: InboxHandlerParameters<TContextData>): Promise<Response>;
80
82
  /**
81
83
  * Options for the {@link respondWithObject} and
82
84
  * {@link respondWithObjectIfAcceptable} functions.
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,QAAQ,EAER,IAAI,EACJ,MAAM,EAGP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK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OAAO,EAChB,EACE,MAAM,EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CA0InB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,aAAa,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,QAAQ,EAER,IAAI,EACJ,MAAM,EAGP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,C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EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,KAAK,EACL,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CAuKnB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,aAAa,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
@@ -8,6 +8,7 @@ import type { ActorDispatcher, ActorKeyPairDispatcher, ActorKeyPairsDispatcher,
8
8
  import type { Context, RequestContext, SendActivityOptions } from "./context.js";
9
9
  import type { KvKey, KvStore } from "./kv.js";
10
10
  import type { MessageQueue } from "./mq.js";
11
+ import { type RetryPolicy } from "./retry.js";
11
12
  import { type SenderKeyPair } from "./send.js";
12
13
  /**
13
14
  * Options for {@link createFederation} function.
@@ -60,12 +61,26 @@ export interface CreateFederationOptions {
60
61
  * the window is a minute.
61
62
  */
62
63
  signatureTimeWindow?: dntShim.Temporal.DurationLike;
64
+ /**
65
+ * The retry policy for sending activities to recipients' inboxes.
66
+ * By default, this uses an exponential backoff strategy with a maximum of
67
+ * 10 attempts and a maximum delay of 12 hours.
68
+ * @since 0.12.0
69
+ */
70
+ outboxRetryPolicy?: RetryPolicy;
71
+ /**
72
+ * The retry policy for processing incoming activities. By default, this
73
+ * uses an exponential backoff strategy with a maximum of 10 attempts and a
74
+ * maximum delay of 12 hours.
75
+ * @since 0.12.0
76
+ */
77
+ inboxRetryPolicy?: RetryPolicy;
63
78
  }
64
79
  /**
65
80
  * Parameters for initializing a {@link Federation} instance.
66
81
  * @deprecated
67
82
  */
68
- export interface FederationParameters extends CreateFederationOptions {
83
+ export interface FederationParameters extends Omit<CreateFederationOptions, "outboxRetryPolicy" | "inboxRetryPolicy"> {
69
84
  /**
70
85
  * The message queue for sending activities to recipients' inboxes.
71
86
  * If not provided, activities will not be queued and will be sent
@@ -118,7 +133,6 @@ export interface FederationParameters extends CreateFederationOptions {
118
133
  * @deprecated
119
134
  */
120
135
  treatHttps?: boolean;
121
- backoffSchedule?: dntShim.Temporal.Duration[];
122
136
  }
123
137
  /**
124
138
  * Prefixes for namespacing keys in the Deno KV store.
@@ -156,7 +170,7 @@ export declare class Federation<TContextData> {
156
170
  * @param parameters Parameters for initializing the instance.
157
171
  * @deprecated Use {@link createFederation} method instead.
158
172
  */
159
- constructor(options: FederationParameters);
173
+ constructor(parameters: FederationParameters);
160
174
  /**
161
175
  * Create a new context.
162
176
  * @param baseUrl The base URL of the server. The `pathname` remains root,
@@ -451,8 +465,9 @@ export declare class Federation<TContextData> {
451
465
  * @param activity The activity to send.
452
466
  * @param options Options for sending the activity.
453
467
  * @throws {TypeError} If the activity to send does not have an actor.
468
+ * @deprecated Use {@link Context.sendActivity} instead.
454
469
  */
455
- sendActivity(keys: SenderKeyPair[], recipients: Recipient | Recipient[], activity: Activity, { preferSharedInbox, immediate, excludeBaseUris, collectionSync }?: SendActivityInternalOptions): Promise<void>;
470
+ sendActivity(keys: SenderKeyPair[], recipients: Recipient | Recipient[], activity: Activity, options: SendActivityInternalOptions<TContextData>): Promise<void>;
456
471
  /**
457
472
  * Handles a request related to federation. If a request is not related to
458
473
  * federation, the `onNotFound` or `onNotAcceptable` callback is called.
@@ -615,8 +630,9 @@ export interface InboxListenerSetters<TContextData> {
615
630
  */
616
631
  setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
617
632
  }
618
- interface SendActivityInternalOptions extends SendActivityOptions {
633
+ interface SendActivityInternalOptions<TContextData> extends SendActivityOptions {
619
634
  collectionSync?: string;
635
+ contextData: TContextData;
620
636
  }
621
637
  export {};
622
638
  //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,QAAQ,EAER,KAAK,OAAO,EACZ,KAAK,IAAI,EAET,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAEV,OAAO,EAEP,cAAc,EACd,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAQtB,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,EAAE,EAAE,OAAO,CAAC;IAEZ;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE3C;;;;OAIG;IACH,KAAK,CAAC,EA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cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,YAAY,CAAC;CAC3B"}
@@ -10,6 +10,7 @@ export { respondWithObject, respondWithObjectIfAcceptable, type RespondWithObjec
10
10
  export * from "./kv.js";
11
11
  export * from "./middleware.js";
12
12
  export * from "./mq.js";
13
+ export * from "./retry.js";
13
14
  export * from "./router.js";
14
15
  export { type SenderKeyPair } from "./send.js";
15
16
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/federation/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,cAAc,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/federation/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,cAAc,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -7,6 +7,8 @@ import * as dntShim from "../_dnt.shims.js";
7
7
  export interface MessageQueueEnqueueOptions {
8
8
  /**
9
9
  * The delay before the message is enqueued. No delay by default.
10
+ *
11
+ * It must not be negative.
10
12
  */
11
13
  delay?: dntShim.Temporal.Duration;
12
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../src/federation/mq.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;CAC/D;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAGxD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1E;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;CAG9D"}
1
+ {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../src/federation/mq.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;CAC/D;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAGxD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1E;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;CAG9D"}
@@ -3,12 +3,22 @@ export interface SenderKeyJwkPair {
3
3
  keyId: string;
4
4
  privateKey: dntShim.JsonWebKey;
5
5
  }
6
+ export type Message = OutboxMessage | InboxMessage;
6
7
  export interface OutboxMessage {
7
8
  type: "outbox";
8
9
  keys: SenderKeyJwkPair[];
9
10
  activity: unknown;
10
11
  inbox: string;
11
- trial: number;
12
+ started: string;
13
+ attempt: number;
12
14
  headers: Record<string, string>;
13
15
  }
16
+ export interface InboxMessage {
17
+ type: "inbox";
18
+ baseUrl: string;
19
+ activity: unknown;
20
+ started: string;
21
+ attempt: number;
22
+ handle: string | null;
23
+ }
14
24
  //# sourceMappingURL=queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/federation/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/federation/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;CAChC;AAED,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The context passed to a {@link RetryPolicy} callback.
3
+ * @since 0.12.0
4
+ */
5
+ import * as dntShim from "../_dnt.shims.js";
6
+ export interface RetryContext {
7
+ /**
8
+ * The elapsed time since the first attempt.
9
+ */
10
+ readonly elapsedTime: dntShim.Temporal.Duration;
11
+ /**
12
+ * The number of attempts so far.
13
+ */
14
+ readonly attempts: number;
15
+ }
16
+ /**
17
+ * A policy that determines the delay before the next retry.
18
+ * @param context The retry context.
19
+ * @returns The delay before the next retry, or `null` to stop retrying.
20
+ * It must not negative.
21
+ * @since 0.12.0
22
+ */
23
+ export type RetryPolicy = (context: RetryContext) => dntShim.Temporal.Duration | null;
24
+ /**
25
+ * Options for {@link createExponentialBackoffPolicy} function.
26
+ * @since 0.12.0
27
+ */
28
+ export interface CreateExponentialBackoffPolicyOptions {
29
+ /**
30
+ * The initial delay before the first retry. Defaults to 1 second.
31
+ */
32
+ readonly initialDelay?: dntShim.Temporal.DurationLike;
33
+ /**
34
+ * The maximum delay between retries. Defaults to 12 hours.
35
+ */
36
+ readonly maxDelay?: dntShim.Temporal.DurationLike;
37
+ /**
38
+ * The maximum number of attempts before giving up.
39
+ * Defaults to 10.
40
+ */
41
+ readonly maxAttempts?: number;
42
+ /**
43
+ * The factor to multiply the previous delay by for each retry.
44
+ * Defaults to 2.
45
+ */
46
+ readonly factor?: number;
47
+ /**
48
+ * Whether to add jitter to the delay to avoid synchronization.
49
+ * Turned on by default.
50
+ */
51
+ readonly jitter?: boolean;
52
+ }
53
+ /**
54
+ * Creates an exponential backoff retry policy. The delay between retries
55
+ * starts at the `initialDelay` and is multiplied by the `factor` for each
56
+ * subsequent retry, up to the `maxDelay`. The policy will give up after
57
+ * `maxAttempts` attempts. The actual delay is randomized to avoid
58
+ * synchronization (jitter).
59
+ * @param options The options for the policy.
60
+ * @returns The retry policy.
61
+ * @since 0.12.0
62
+ */
63
+ export declare function createExponentialBackoffPolicy(options?: CreateExponentialBackoffPolicyOptions): RetryPolicy;
64
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/federation/retry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAEhD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;AAEtF;;;GAGG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAElD;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,qCAA0C,GAClD,WAAW,CAmBb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.test.d.ts","sourceRoot":"","sources":["../../src/federation/retry.test.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}