@fedify/fedify 2.2.0 → 2.3.0-dev.1013
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/{builder-DPgHJ5o_.mjs → builder-CROLcFVM.mjs} +2 -2
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-DJGagtNd.d.cts → context-BDl7Y6f-.d.cts} +41 -1
- package/dist/{context-BzH2-ajs.d.ts → context-zTZAI3KP.d.ts} +41 -1
- package/dist/{deno-_w-iVcdO.mjs → deno-Ctd-K-t6.mjs} +1 -1
- package/dist/{docloader-6U94xZpT.mjs → docloader-q9QT51g3.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/middleware.test.mjs +6 -6
- package/dist/federation/mod.cjs +38 -12
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +38 -12
- package/dist/federation/mq.test.mjs +172 -11
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-DL2gLW-Q.js → http-1NL30qCe.js} +1 -1
- package/dist/{http-DfbPyJdT.mjs → http-CX_zHeOD.mjs} +2 -2
- package/dist/{http-BJEiRovv.cjs → http-Du1Jgf2P.cjs} +1 -1
- package/dist/{key-oqniN9pm.mjs → key-C1Oto4it.mjs} +1 -1
- package/dist/{kv-cache-DBPfVPsx.js → kv-cache-CsC3P4uu.js} +1 -1
- package/dist/{kv-cache-CsLyBv6_.cjs → kv-cache-aGOwL6Vj.cjs} +1 -1
- package/dist/{ld-DXwhdVuu.mjs → ld-Dl1HIB1a.mjs} +2 -2
- package/dist/{middleware-D5TtCEtU.cjs → middleware-BiFLcrEX.cjs} +4 -4
- package/dist/{middleware-bZpyiB8S.cjs → middleware-BwC5U8zJ.cjs} +1 -1
- package/dist/{middleware-GnTsk2j7.mjs → middleware-C1cf3_6V.mjs} +1 -1
- package/dist/{middleware-BOV-iBXF.mjs → middleware-CEWDB8EB.mjs} +9 -9
- package/dist/{middleware-CcyI5ZB-.js → middleware-CKJC8DRf.js} +3 -3
- package/dist/{mod-D35TRn09.d.cts → mod-BghZgD_U.d.cts} +1 -1
- package/dist/{mod-2d12ffz3.d.ts → mod-ckCOmoCz.d.ts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/{owner-C-l7eGo5.mjs → owner-CEWFJlqo.mjs} +2 -2
- package/dist/{proof-vcC_p7Cg.mjs → proof-BFyPVl1r.mjs} +2 -2
- package/dist/{proof-CrovtVDA.cjs → proof-CDA3f-i5.cjs} +1 -1
- package/dist/{proof-CLd2ZZin.js → proof-Dedf8md5.js} +1 -1
- package/dist/{send-CqjPhWLS.mjs → send-BJickEP4.mjs} +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +2 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +1 -1
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
+
import { n as version, t as name } from "./deno-Ctd-K-t6.mjs";
|
|
6
6
|
import { t as ActivityListenerSet } from "./activity-listener-ell7W1s9.mjs";
|
|
7
7
|
import { Tombstone, getTypeId } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -58,7 +58,7 @@ var FederationBuilderImpl = class {
|
|
|
58
58
|
this.collectionTypeIds = {};
|
|
59
59
|
}
|
|
60
60
|
async build(options) {
|
|
61
|
-
const { FederationImpl } = await import("./middleware-
|
|
61
|
+
const { FederationImpl } = await import("./middleware-C1cf3_6V.mjs");
|
|
62
62
|
const f = new FederationImpl(options);
|
|
63
63
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
64
64
|
f.router = this.router.clone();
|
package/dist/compat/mod.d.cts
CHANGED
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import {
|
|
3
|
+
import { kt as ActivityTransformer, n as Context } from "../context-zTZAI3KP.js";
|
|
4
4
|
import { Activity } from "@fedify/vocab";
|
|
5
5
|
|
|
6
6
|
//#region src/compat/transformers.d.ts
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
6
6
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
8
|
-
import { n as FederationImpl, v as actorDehydrator, y as autoIdAssigner } from "../middleware-
|
|
8
|
+
import { n as FederationImpl, v as actorDehydrator, y as autoIdAssigner } from "../middleware-CEWDB8EB.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Follow, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/compat/transformers.test.ts
|
|
@@ -418,6 +418,34 @@ interface MessageQueueListenOptions {
|
|
|
418
418
|
signal?: AbortSignal;
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
|
+
* The number of messages waiting in a message queue.
|
|
422
|
+
*
|
|
423
|
+
* @since 2.3.0
|
|
424
|
+
*/
|
|
425
|
+
interface MessageQueueDepth {
|
|
426
|
+
/**
|
|
427
|
+
* The total number of messages still waiting in the backend queue.
|
|
428
|
+
*
|
|
429
|
+
* This does not include messages that have already been handed to a worker
|
|
430
|
+
* for processing.
|
|
431
|
+
*/
|
|
432
|
+
readonly queued: number;
|
|
433
|
+
/**
|
|
434
|
+
* The number of queued messages eligible for immediate processing.
|
|
435
|
+
*
|
|
436
|
+
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
437
|
+
* may omit this field.
|
|
438
|
+
*/
|
|
439
|
+
readonly ready?: number;
|
|
440
|
+
/**
|
|
441
|
+
* The number of queued messages scheduled for later delivery.
|
|
442
|
+
*
|
|
443
|
+
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
444
|
+
* may omit this field.
|
|
445
|
+
*/
|
|
446
|
+
readonly delayed?: number;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
421
449
|
* An abstract interface for a message queue.
|
|
422
450
|
*
|
|
423
451
|
* @since 0.5.0
|
|
@@ -457,6 +485,16 @@ interface MessageQueue {
|
|
|
457
485
|
* signal is provided, it never resolves.
|
|
458
486
|
*/
|
|
459
487
|
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
488
|
+
/**
|
|
489
|
+
* Gets the number of messages waiting in the queue.
|
|
490
|
+
*
|
|
491
|
+
* This operation is optional, and may not be supported by all
|
|
492
|
+
* implementations. The returned counts exclude messages currently being
|
|
493
|
+
* handled by a worker.
|
|
494
|
+
*
|
|
495
|
+
* @since 2.3.0
|
|
496
|
+
*/
|
|
497
|
+
getDepth?(): Promise<MessageQueueDepth>;
|
|
460
498
|
}
|
|
461
499
|
/**
|
|
462
500
|
* Additional options for {@link InProcessMessageQueue}.
|
|
@@ -491,6 +529,7 @@ declare class InProcessMessageQueue implements MessageQueue {
|
|
|
491
529
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
492
530
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
493
531
|
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
532
|
+
getDepth(): Promise<MessageQueueDepth>;
|
|
494
533
|
}
|
|
495
534
|
/**
|
|
496
535
|
* A message queue that processes messages in parallel. It takes another
|
|
@@ -531,6 +570,7 @@ declare class ParallelMessageQueue implements MessageQueue {
|
|
|
531
570
|
* @since 1.7.0
|
|
532
571
|
*/
|
|
533
572
|
readonly nativeRetrial?: boolean;
|
|
573
|
+
readonly getDepth?: () => Promise<MessageQueueDepth>;
|
|
534
574
|
/**
|
|
535
575
|
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
536
576
|
* number of workers.
|
|
@@ -2806,4 +2846,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2806
2846
|
readonly multikey: Multikey;
|
|
2807
2847
|
}
|
|
2808
2848
|
//#endregion
|
|
2809
|
-
export {
|
|
2849
|
+
export { ParallelMessageQueue as $, FederationKvPrefixes as A, Router as B, IdempotencyKeyCallback as C, WebFingerLinksDispatcher as Ct, ObjectCallbackSetters as D, buildCollectionSynchronizationHeader as Dt, InboxListenerSetters as E, PageItems as Et, RetryContext as F, respondWithObject as G, RouterOptions as H, RetryPolicy as I, InProcessMessageQueueOptions as J, respondWithObjectIfAcceptable as K, createExponentialBackoffPolicy as L, FederationQueueOptions as M, createFederation as N, OutboxListenerSetters as O, digest as Ot, CreateExponentialBackoffPolicyOptions as P, MessageQueueListenOptions as Q, Message as R, FederationStartQueueOptions as S, UnverifiedActivityReason as St, InboxChallengePolicy as T, SenderKeyPair as Tt, RouterRouteResult as U, RouterError as V, RespondWithObjectOptions as W, MessageQueueDepth as X, MessageQueue as Y, MessageQueueEnqueueOptions as Z, Federatable as _, OutboxListener as _t, GetSignedKeyOptions as a, CollectionCounter as at, FederationFetchOptions as b, SharedInboxKeyDispatcher as bt, ParseUriResult as c, CustomCollectionCounter as ct, SendActivityOptions as d, InboxErrorHandler as dt, ActorAliasMapper as et, SendActivityOptionsForCollection as f, InboxListener as ft, CustomCollectionCallbackSetters as g, OutboxErrorHandler as gt, ConstructorWithTypeId as h, ObjectDispatcher as ht, GetActorOptions as i, AuthorizePredicate as it, FederationOrigin as j, Rfc6570Expression as k, ActivityTransformer as kt, RequestContext as l, CustomCollectionCursor as lt, CollectionCallbackSetters as m, ObjectAuthorizePredicate as mt, Context as n, ActorHandleMapper as nt, InboxContext as o, CollectionCursor as ot, ActorCallbackSetters as p, NodeInfoDispatcher as pt, InProcessMessageQueue as q, ForwardActivityOptions as r, ActorKeyPairsDispatcher as rt, OutboxContext as s, CollectionDispatcher as st, ActorKeyPair as t, ActorDispatcher as tt, RouteActivityOptions as u, CustomCollectionDispatcher as ut, Federation as v, OutboxListenerErrorHandler as vt, IdempotencyStrategy as w, SendActivityError as wt, FederationOptions as x, UnverifiedActivityHandler as xt, FederationBuilder as y, OutboxPermanentFailureHandler as yt, createFederationBuilder as z };
|
|
@@ -420,6 +420,34 @@ interface MessageQueueListenOptions {
|
|
|
420
420
|
signal?: AbortSignal;
|
|
421
421
|
}
|
|
422
422
|
/**
|
|
423
|
+
* The number of messages waiting in a message queue.
|
|
424
|
+
*
|
|
425
|
+
* @since 2.3.0
|
|
426
|
+
*/
|
|
427
|
+
interface MessageQueueDepth {
|
|
428
|
+
/**
|
|
429
|
+
* The total number of messages still waiting in the backend queue.
|
|
430
|
+
*
|
|
431
|
+
* This does not include messages that have already been handed to a worker
|
|
432
|
+
* for processing.
|
|
433
|
+
*/
|
|
434
|
+
readonly queued: number;
|
|
435
|
+
/**
|
|
436
|
+
* The number of queued messages eligible for immediate processing.
|
|
437
|
+
*
|
|
438
|
+
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
439
|
+
* may omit this field.
|
|
440
|
+
*/
|
|
441
|
+
readonly ready?: number;
|
|
442
|
+
/**
|
|
443
|
+
* The number of queued messages scheduled for later delivery.
|
|
444
|
+
*
|
|
445
|
+
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
446
|
+
* may omit this field.
|
|
447
|
+
*/
|
|
448
|
+
readonly delayed?: number;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
423
451
|
* An abstract interface for a message queue.
|
|
424
452
|
*
|
|
425
453
|
* @since 0.5.0
|
|
@@ -459,6 +487,16 @@ interface MessageQueue {
|
|
|
459
487
|
* signal is provided, it never resolves.
|
|
460
488
|
*/
|
|
461
489
|
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
490
|
+
/**
|
|
491
|
+
* Gets the number of messages waiting in the queue.
|
|
492
|
+
*
|
|
493
|
+
* This operation is optional, and may not be supported by all
|
|
494
|
+
* implementations. The returned counts exclude messages currently being
|
|
495
|
+
* handled by a worker.
|
|
496
|
+
*
|
|
497
|
+
* @since 2.3.0
|
|
498
|
+
*/
|
|
499
|
+
getDepth?(): Promise<MessageQueueDepth>;
|
|
462
500
|
}
|
|
463
501
|
/**
|
|
464
502
|
* Additional options for {@link InProcessMessageQueue}.
|
|
@@ -493,6 +531,7 @@ declare class InProcessMessageQueue implements MessageQueue {
|
|
|
493
531
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
494
532
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
495
533
|
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
534
|
+
getDepth(): Promise<MessageQueueDepth>;
|
|
496
535
|
}
|
|
497
536
|
/**
|
|
498
537
|
* A message queue that processes messages in parallel. It takes another
|
|
@@ -533,6 +572,7 @@ declare class ParallelMessageQueue implements MessageQueue {
|
|
|
533
572
|
* @since 1.7.0
|
|
534
573
|
*/
|
|
535
574
|
readonly nativeRetrial?: boolean;
|
|
575
|
+
readonly getDepth?: () => Promise<MessageQueueDepth>;
|
|
536
576
|
/**
|
|
537
577
|
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
538
578
|
* number of workers.
|
|
@@ -2808,4 +2848,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2808
2848
|
readonly multikey: Multikey;
|
|
2809
2849
|
}
|
|
2810
2850
|
//#endregion
|
|
2811
|
-
export {
|
|
2851
|
+
export { ParallelMessageQueue as $, FederationKvPrefixes as A, Router as B, IdempotencyKeyCallback as C, WebFingerLinksDispatcher as Ct, ObjectCallbackSetters as D, buildCollectionSynchronizationHeader as Dt, InboxListenerSetters as E, PageItems as Et, RetryContext as F, respondWithObject as G, RouterOptions as H, RetryPolicy as I, InProcessMessageQueueOptions as J, respondWithObjectIfAcceptable as K, createExponentialBackoffPolicy as L, FederationQueueOptions as M, createFederation as N, OutboxListenerSetters as O, digest as Ot, CreateExponentialBackoffPolicyOptions as P, MessageQueueListenOptions as Q, Message as R, FederationStartQueueOptions as S, UnverifiedActivityReason as St, InboxChallengePolicy as T, SenderKeyPair as Tt, RouterRouteResult as U, RouterError as V, RespondWithObjectOptions as W, MessageQueueDepth as X, MessageQueue as Y, MessageQueueEnqueueOptions as Z, Federatable as _, OutboxListener as _t, GetSignedKeyOptions as a, CollectionCounter as at, FederationFetchOptions as b, SharedInboxKeyDispatcher as bt, ParseUriResult as c, CustomCollectionCounter as ct, SendActivityOptions as d, InboxErrorHandler as dt, ActorAliasMapper as et, SendActivityOptionsForCollection as f, InboxListener as ft, CustomCollectionCallbackSetters as g, OutboxErrorHandler as gt, ConstructorWithTypeId as h, ObjectDispatcher as ht, GetActorOptions as i, AuthorizePredicate as it, FederationOrigin as j, Rfc6570Expression as k, ActivityTransformer as kt, RequestContext as l, CustomCollectionCursor as lt, CollectionCallbackSetters as m, ObjectAuthorizePredicate as mt, Context as n, ActorHandleMapper as nt, InboxContext as o, CollectionCursor as ot, ActorCallbackSetters as p, NodeInfoDispatcher as pt, InProcessMessageQueue as q, ForwardActivityOptions as r, ActorKeyPairsDispatcher as rt, OutboxContext as s, CollectionDispatcher as st, ActorKeyPair as t, ActorDispatcher as tt, RouteActivityOptions as u, CustomCollectionDispatcher as ut, Federation as v, OutboxListenerErrorHandler as vt, IdempotencyStrategy as w, SendActivityError as wt, FederationOptions as x, UnverifiedActivityHandler as xt, FederationBuilder as y, OutboxPermanentFailureHandler as yt, createFederationBuilder as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { o as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { o as validateCryptoKey } from "./key-C1Oto4it.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-CX_zHeOD.mjs";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
7
7
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -6,7 +6,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
6
6
|
import { i as assertExists } from "../std__assert-CRDpx_HF.mjs";
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
8
8
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
9
|
-
import { n as createFederationBuilder } from "../builder-
|
|
9
|
+
import { n as createFederationBuilder } from "../builder-CROLcFVM.mjs";
|
|
10
10
|
import { test } from "@fedify/fixture";
|
|
11
11
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
12
12
|
//#region src/federation/builder.test.ts
|
|
@@ -7,10 +7,10 @@ import "../std__assert-CRDpx_HF.mjs";
|
|
|
7
7
|
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
8
8
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
9
9
|
import { r as parseAcceptSignature } from "../accept-CPkZzmGN.mjs";
|
|
10
|
-
import { s as signRequest } from "../http-
|
|
10
|
+
import { s as signRequest } from "../http-CX_zHeOD.mjs";
|
|
11
11
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
|
|
12
12
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
13
|
-
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-
|
|
13
|
+
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-CEWDB8EB.mjs";
|
|
14
14
|
import { t as ActivityListenerSet } from "../activity-listener-ell7W1s9.mjs";
|
|
15
15
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
16
16
|
import { Activity, Create, Note, Person, Tombstone } from "@fedify/vocab";
|
|
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
6
|
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
7
|
-
import { r as signObject } from "../proof-
|
|
7
|
+
import { r as signObject } from "../proof-BFyPVl1r.mjs";
|
|
8
8
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
9
|
-
import { o as createFederation } from "../middleware-
|
|
9
|
+
import { o as createFederation } from "../middleware-CEWDB8EB.mjs";
|
|
10
10
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
12
12
|
//#region src/federation/idempotency.test.ts
|
|
@@ -11,14 +11,14 @@ import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
|
11
11
|
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
12
12
|
import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
|
|
13
13
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
14
|
-
import { l as verifyRequest, s as signRequest } from "../http-
|
|
14
|
+
import { l as verifyRequest, s as signRequest } from "../http-CX_zHeOD.mjs";
|
|
15
15
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
16
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
17
|
-
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-
|
|
18
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
19
|
-
import { i as verifyObject, r as signObject } from "../proof-
|
|
16
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-q9QT51g3.mjs";
|
|
17
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-Dl1HIB1a.mjs";
|
|
18
|
+
import { t as doesActorOwnKey } from "../owner-CEWFJlqo.mjs";
|
|
19
|
+
import { i as verifyObject, r as signObject } from "../proof-BFyPVl1r.mjs";
|
|
20
20
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
21
|
-
import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-
|
|
21
|
+
import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-CEWDB8EB.mjs";
|
|
22
22
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
23
23
|
import * as vocab from "@fedify/vocab";
|
|
24
24
|
import { getTypeId, lookupObject } from "@fedify/vocab";
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
require("../chunk-DDcVe30Y.cjs");
|
|
5
|
-
const require_middleware = require("../middleware-
|
|
5
|
+
const require_middleware = require("../middleware-BiFLcrEX.cjs");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
//#region src/federation/kv.ts
|
|
8
8
|
/**
|
|
@@ -103,6 +103,7 @@ var InProcessMessageQueue = class {
|
|
|
103
103
|
#messages;
|
|
104
104
|
#monitors;
|
|
105
105
|
#pollIntervalMs;
|
|
106
|
+
#delayedMessages;
|
|
106
107
|
/**
|
|
107
108
|
* Tracks which ordering keys are currently being processed to ensure
|
|
108
109
|
* sequential processing for messages with the same key.
|
|
@@ -121,42 +122,56 @@ var InProcessMessageQueue = class {
|
|
|
121
122
|
this.#messages = [];
|
|
122
123
|
this.#monitors = {};
|
|
123
124
|
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
125
|
+
this.#delayedMessages = 0;
|
|
124
126
|
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
125
127
|
}
|
|
126
128
|
enqueue(message, options) {
|
|
127
129
|
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
128
130
|
if (delay > 0) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
this.#delayedMessages++;
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
this.#delayedMessages--;
|
|
134
|
+
this.#enqueueReady(message, options);
|
|
135
|
+
}, delay);
|
|
133
136
|
return Promise.resolve();
|
|
134
137
|
}
|
|
138
|
+
this.#enqueueReady(message, options);
|
|
139
|
+
return Promise.resolve();
|
|
140
|
+
}
|
|
141
|
+
#enqueueReady(message, options) {
|
|
135
142
|
const orderingKey = options?.orderingKey ?? null;
|
|
136
143
|
this.#messages.push({
|
|
137
144
|
message,
|
|
138
145
|
orderingKey
|
|
139
146
|
});
|
|
147
|
+
this.#notifyMonitors();
|
|
148
|
+
}
|
|
149
|
+
#notifyMonitors() {
|
|
140
150
|
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
141
|
-
return Promise.resolve();
|
|
142
151
|
}
|
|
143
152
|
enqueueMany(messages, options) {
|
|
144
153
|
if (messages.length === 0) return Promise.resolve();
|
|
145
154
|
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
146
155
|
if (delay > 0) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
156
|
+
const delayedCount = messages.length;
|
|
157
|
+
const deferredMessages = [...messages];
|
|
158
|
+
this.#delayedMessages += delayedCount;
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
this.#delayedMessages -= delayedCount;
|
|
161
|
+
this.#enqueueManyReady(deferredMessages, options);
|
|
162
|
+
}, delay);
|
|
151
163
|
return Promise.resolve();
|
|
152
164
|
}
|
|
165
|
+
this.#enqueueManyReady(messages, options);
|
|
166
|
+
return Promise.resolve();
|
|
167
|
+
}
|
|
168
|
+
#enqueueManyReady(messages, options) {
|
|
153
169
|
const orderingKey = options?.orderingKey ?? null;
|
|
154
170
|
for (const message of messages) this.#messages.push({
|
|
155
171
|
message,
|
|
156
172
|
orderingKey
|
|
157
173
|
});
|
|
158
|
-
|
|
159
|
-
return Promise.resolve();
|
|
174
|
+
this.#notifyMonitors();
|
|
160
175
|
}
|
|
161
176
|
async listen(handler, options = {}) {
|
|
162
177
|
const signal = options.signal;
|
|
@@ -174,6 +189,15 @@ var InProcessMessageQueue = class {
|
|
|
174
189
|
else await this.#wait(10, signal);
|
|
175
190
|
}
|
|
176
191
|
}
|
|
192
|
+
getDepth() {
|
|
193
|
+
const ready = this.#messages.length;
|
|
194
|
+
const delayed = this.#delayedMessages;
|
|
195
|
+
return Promise.resolve({
|
|
196
|
+
queued: ready + delayed,
|
|
197
|
+
ready,
|
|
198
|
+
delayed
|
|
199
|
+
});
|
|
200
|
+
}
|
|
177
201
|
#wait(ms, signal) {
|
|
178
202
|
let timer = null;
|
|
179
203
|
return Promise.any([new Promise((resolve) => {
|
|
@@ -228,6 +252,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
228
252
|
* @since 1.7.0
|
|
229
253
|
*/
|
|
230
254
|
nativeRetrial;
|
|
255
|
+
getDepth;
|
|
231
256
|
/**
|
|
232
257
|
* Tracks which ordering keys are currently being processed to ensure
|
|
233
258
|
* sequential processing for messages with the same key.
|
|
@@ -251,6 +276,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
251
276
|
this.queue = queue;
|
|
252
277
|
this.workers = workers;
|
|
253
278
|
this.nativeRetrial = queue.nativeRetrial;
|
|
279
|
+
if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
|
|
254
280
|
}
|
|
255
281
|
enqueue(message, options) {
|
|
256
282
|
return this.queue.enqueue(message, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ParallelMessageQueue, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as WebFingerLinksDispatcher, D as ObjectCallbackSetters, Dt as buildCollectionSynchronizationHeader, E as InboxListenerSetters, Et as PageItems, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as digest, P as CreateExponentialBackoffPolicyOptions, Q as MessageQueueListenOptions, R as Message, S as FederationStartQueueOptions, St as UnverifiedActivityReason, T as InboxChallengePolicy, Tt as SenderKeyPair, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueDepth, Y as MessageQueue, Z as MessageQueueEnqueueOptions, _ as Federatable, _t as OutboxListener, a as GetSignedKeyOptions, at as CollectionCounter, b as FederationFetchOptions, bt as SharedInboxKeyDispatcher, c as ParseUriResult, ct as CustomCollectionCounter, d as SendActivityOptions, dt as InboxErrorHandler, et as ActorAliasMapper, f as SendActivityOptionsForCollection, ft as InboxListener, g as CustomCollectionCallbackSetters, gt as OutboxErrorHandler, h as ConstructorWithTypeId, ht as ObjectDispatcher, i as GetActorOptions, it as AuthorizePredicate, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionCursor, m as CollectionCallbackSetters, mt as ObjectAuthorizePredicate, n as Context, nt as ActorHandleMapper, o as InboxContext, ot as CollectionCursor, p as ActorCallbackSetters, pt as NodeInfoDispatcher, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as ActorKeyPairsDispatcher, s as OutboxContext, st as CollectionDispatcher, t as ActorKeyPair, tt as ActorDispatcher, u as RouteActivityOptions, ut as CustomCollectionDispatcher, v as Federation, vt as OutboxListenerErrorHandler, w as IdempotencyStrategy, wt as SendActivityError, x as FederationOptions, xt as UnverifiedActivityHandler, y as FederationBuilder, yt as OutboxPermanentFailureHandler, z as createFederationBuilder } from "../context-BDl7Y6f-.cjs";
|
|
2
2
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-CbLNp3zQ.cjs";
|
|
3
|
-
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-
|
|
4
|
-
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
|
3
|
+
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-BghZgD_U.cjs";
|
|
4
|
+
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as ParallelMessageQueue, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as WebFingerLinksDispatcher, D as ObjectCallbackSetters, Dt as buildCollectionSynchronizationHeader, E as InboxListenerSetters, Et as PageItems, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as digest, P as CreateExponentialBackoffPolicyOptions, Q as MessageQueueListenOptions, R as Message, S as FederationStartQueueOptions, St as UnverifiedActivityReason, T as InboxChallengePolicy, Tt as SenderKeyPair, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueDepth, Y as MessageQueue, Z as MessageQueueEnqueueOptions, _ as Federatable, _t as OutboxListener, a as GetSignedKeyOptions, at as CollectionCounter, b as FederationFetchOptions, bt as SharedInboxKeyDispatcher, c as ParseUriResult, ct as CustomCollectionCounter, d as SendActivityOptions, dt as InboxErrorHandler, et as ActorAliasMapper, f as SendActivityOptionsForCollection, ft as InboxListener, g as CustomCollectionCallbackSetters, gt as OutboxErrorHandler, h as ConstructorWithTypeId, ht as ObjectDispatcher, i as GetActorOptions, it as AuthorizePredicate, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionCursor, m as CollectionCallbackSetters, mt as ObjectAuthorizePredicate, n as Context, nt as ActorHandleMapper, o as InboxContext, ot as CollectionCursor, p as ActorCallbackSetters, pt as NodeInfoDispatcher, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as ActorKeyPairsDispatcher, s as OutboxContext, st as CollectionDispatcher, t as ActorKeyPair, tt as ActorDispatcher, u as RouteActivityOptions, ut as CustomCollectionDispatcher, v as Federation, vt as OutboxListenerErrorHandler, w as IdempotencyStrategy, wt as SendActivityError, x as FederationOptions, xt as UnverifiedActivityHandler, y as FederationBuilder, yt as OutboxPermanentFailureHandler, z as createFederationBuilder } from "../context-zTZAI3KP.js";
|
|
4
4
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-GFYnFoOl.js";
|
|
5
|
-
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-
|
|
6
|
-
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
|
5
|
+
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-ckCOmoCz.js";
|
|
6
|
+
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
|
-
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-
|
|
3
|
+
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-CKJC8DRf.js";
|
|
4
4
|
import { isEqual } from "es-toolkit";
|
|
5
5
|
//#region src/federation/kv.ts
|
|
6
6
|
/**
|
|
@@ -101,6 +101,7 @@ var InProcessMessageQueue = class {
|
|
|
101
101
|
#messages;
|
|
102
102
|
#monitors;
|
|
103
103
|
#pollIntervalMs;
|
|
104
|
+
#delayedMessages;
|
|
104
105
|
/**
|
|
105
106
|
* Tracks which ordering keys are currently being processed to ensure
|
|
106
107
|
* sequential processing for messages with the same key.
|
|
@@ -119,42 +120,56 @@ var InProcessMessageQueue = class {
|
|
|
119
120
|
this.#messages = [];
|
|
120
121
|
this.#monitors = {};
|
|
121
122
|
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
123
|
+
this.#delayedMessages = 0;
|
|
122
124
|
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
123
125
|
}
|
|
124
126
|
enqueue(message, options) {
|
|
125
127
|
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
126
128
|
if (delay > 0) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
this.#delayedMessages++;
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
this.#delayedMessages--;
|
|
132
|
+
this.#enqueueReady(message, options);
|
|
133
|
+
}, delay);
|
|
131
134
|
return Promise.resolve();
|
|
132
135
|
}
|
|
136
|
+
this.#enqueueReady(message, options);
|
|
137
|
+
return Promise.resolve();
|
|
138
|
+
}
|
|
139
|
+
#enqueueReady(message, options) {
|
|
133
140
|
const orderingKey = options?.orderingKey ?? null;
|
|
134
141
|
this.#messages.push({
|
|
135
142
|
message,
|
|
136
143
|
orderingKey
|
|
137
144
|
});
|
|
145
|
+
this.#notifyMonitors();
|
|
146
|
+
}
|
|
147
|
+
#notifyMonitors() {
|
|
138
148
|
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
139
|
-
return Promise.resolve();
|
|
140
149
|
}
|
|
141
150
|
enqueueMany(messages, options) {
|
|
142
151
|
if (messages.length === 0) return Promise.resolve();
|
|
143
152
|
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
144
153
|
if (delay > 0) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
const delayedCount = messages.length;
|
|
155
|
+
const deferredMessages = [...messages];
|
|
156
|
+
this.#delayedMessages += delayedCount;
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.#delayedMessages -= delayedCount;
|
|
159
|
+
this.#enqueueManyReady(deferredMessages, options);
|
|
160
|
+
}, delay);
|
|
149
161
|
return Promise.resolve();
|
|
150
162
|
}
|
|
163
|
+
this.#enqueueManyReady(messages, options);
|
|
164
|
+
return Promise.resolve();
|
|
165
|
+
}
|
|
166
|
+
#enqueueManyReady(messages, options) {
|
|
151
167
|
const orderingKey = options?.orderingKey ?? null;
|
|
152
168
|
for (const message of messages) this.#messages.push({
|
|
153
169
|
message,
|
|
154
170
|
orderingKey
|
|
155
171
|
});
|
|
156
|
-
|
|
157
|
-
return Promise.resolve();
|
|
172
|
+
this.#notifyMonitors();
|
|
158
173
|
}
|
|
159
174
|
async listen(handler, options = {}) {
|
|
160
175
|
const signal = options.signal;
|
|
@@ -172,6 +187,15 @@ var InProcessMessageQueue = class {
|
|
|
172
187
|
else await this.#wait(10, signal);
|
|
173
188
|
}
|
|
174
189
|
}
|
|
190
|
+
getDepth() {
|
|
191
|
+
const ready = this.#messages.length;
|
|
192
|
+
const delayed = this.#delayedMessages;
|
|
193
|
+
return Promise.resolve({
|
|
194
|
+
queued: ready + delayed,
|
|
195
|
+
ready,
|
|
196
|
+
delayed
|
|
197
|
+
});
|
|
198
|
+
}
|
|
175
199
|
#wait(ms, signal) {
|
|
176
200
|
let timer = null;
|
|
177
201
|
return Promise.any([new Promise((resolve) => {
|
|
@@ -226,6 +250,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
226
250
|
* @since 1.7.0
|
|
227
251
|
*/
|
|
228
252
|
nativeRetrial;
|
|
253
|
+
getDepth;
|
|
229
254
|
/**
|
|
230
255
|
* Tracks which ordering keys are currently being processed to ensure
|
|
231
256
|
* sequential processing for messages with the same key.
|
|
@@ -249,6 +274,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
249
274
|
this.queue = queue;
|
|
250
275
|
this.workers = workers;
|
|
251
276
|
this.nativeRetrial = queue.nativeRetrial;
|
|
277
|
+
if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
|
|
252
278
|
}
|
|
253
279
|
enqueue(message, options) {
|
|
254
280
|
return this.queue.enqueue(message, options);
|