@trigger.dev/redis-worker 4.7.3 → 4.7.5
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/index.cjs +472 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -18
- package/dist/index.d.ts +163 -18
- package/dist/index.js +467 -60
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Callback,
|
|
1
|
+
import { Callback, RedisClient, RedisClusterClientOptions, RedisOptions, Result } from "@internal/redis";
|
|
2
2
|
import { Logger } from "@trigger.dev/core/logger";
|
|
3
3
|
import { AnyZodSchema, inferZodSchemaOutput } from "@trigger.dev/core/v3";
|
|
4
4
|
import { Attributes, Context, Counter, Histogram, Meter, ObservableGauge, Span, SpanKind, Tracer } from "@internal/tracing";
|
|
@@ -51,6 +51,22 @@ declare class SimpleQueue<TMessageCatalog extends MessageCatalogSchema> {
|
|
|
51
51
|
visibilityTimeoutMs: number;
|
|
52
52
|
cancellationKey?: string;
|
|
53
53
|
}): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Re-enqueues an item for a retry, unless since it was dequeued a newer enqueue replaced it (its
|
|
56
|
+
* stored deduplication key no longer matches) or it was removed by an ack or cancel. Returns
|
|
57
|
+
* false when it skipped, so a failed attempt never overwrites the newer item or revives a removed
|
|
58
|
+
* one. A newer enqueue starts its own retry budget: an item a handler re-enqueues before failing
|
|
59
|
+
* restarts at attempt 0 rather than moving towards the DLQ.
|
|
60
|
+
*/
|
|
61
|
+
requeue({ id, job, item, attempt, availableAt, visibilityTimeoutMs, deduplicationKey }: {
|
|
62
|
+
id: string;
|
|
63
|
+
job: MessageCatalogKey<TMessageCatalog>;
|
|
64
|
+
item: MessageCatalogValue<TMessageCatalog, MessageCatalogKey<TMessageCatalog>>;
|
|
65
|
+
attempt: number;
|
|
66
|
+
availableAt: Date;
|
|
67
|
+
visibilityTimeoutMs: number;
|
|
68
|
+
deduplicationKey?: string;
|
|
69
|
+
}): Promise<boolean>;
|
|
54
70
|
enqueueOnce({ id, job, item, attempt, availableAt, visibilityTimeoutMs }: {
|
|
55
71
|
id: string;
|
|
56
72
|
job: MessageCatalogKey<TMessageCatalog>;
|
|
@@ -82,7 +98,11 @@ declare class SimpleQueue<TMessageCatalog extends MessageCatalogSchema> {
|
|
|
82
98
|
*/
|
|
83
99
|
oldestMessageAge(): Promise<number>;
|
|
84
100
|
getJob(id: string): Promise<QueueItem<TMessageCatalog> | null>;
|
|
85
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Moves an item to the dead letter queue. With a deduplication key, an item a newer enqueue has
|
|
103
|
+
* replaced is left in the queue and false is returned.
|
|
104
|
+
*/
|
|
105
|
+
moveToDeadLetterQueue(id: string, errorMessage: string, deduplicationKey?: string): Promise<boolean>;
|
|
86
106
|
sizeOfDeadLetterQueue(): Promise<number>;
|
|
87
107
|
redriveFromDeadLetterQueue(id: string): Promise<void>;
|
|
88
108
|
close(): Promise<void>;
|
|
@@ -94,7 +114,8 @@ declare module "@internal/redis" {
|
|
|
94
114
|
dequeueItems(queue: string, items: string, now: number, count: number, callback?: Callback<Array<[string, string, string]>>): Result<Array<[string, string, string]>, Context>;
|
|
95
115
|
ackItem(queue: string, items: string, id: string, deduplicationKey: string, callback?: Callback<number>): Result<number, Context>;
|
|
96
116
|
redriveFromDeadLetterQueue(queue: string, items: string, dlq: string, dlqItems: string, id: string, callback?: Callback<number>): Result<number, Context>;
|
|
97
|
-
moveToDeadLetterQueue(queue: string, items: string, dlq: string, dlqItems: string, id: string, errorMessage: string, callback?: Callback<number>): Result<number, Context>;
|
|
117
|
+
moveToDeadLetterQueue(queue: string, items: string, dlq: string, dlqItems: string, id: string, errorMessage: string, deduplicationKey: string, callback?: Callback<number>): Result<number, Context>;
|
|
118
|
+
requeueItem(queue: string, items: string, id: string, score: number, serializedItem: string, deduplicationKey: string, callback?: Callback<number>): Result<number, Context>;
|
|
98
119
|
enqueueItemOnce(queue: string, items: string, id: string, score: number, serializedItem: string, callback?: Callback<number>): Result<number, Context>;
|
|
99
120
|
getJob(queue: string, items: string, id: string, callback?: Callback<[string, string, string] | null>): Result<[string, string, string] | null, Context>;
|
|
100
121
|
getOldestDueScore(queue: string, items: string, now: number, callback?: Callback<string | number>): Result<string | number, Context>;
|
|
@@ -262,9 +283,6 @@ declare class Worker<TCatalog extends WorkerCatalog> {
|
|
|
262
283
|
* Processes a batch of items for a batch-enabled job type.
|
|
263
284
|
*/
|
|
264
285
|
private processBatch;
|
|
265
|
-
/**
|
|
266
|
-
* Processes a single item.
|
|
267
|
-
*/
|
|
268
286
|
private processItem;
|
|
269
287
|
private withHistogram;
|
|
270
288
|
private static delay;
|
|
@@ -290,6 +308,26 @@ declare class Worker<TCatalog extends WorkerCatalog> {
|
|
|
290
308
|
*/
|
|
291
309
|
declare function isAbortError(error: unknown): boolean;
|
|
292
310
|
//#endregion
|
|
311
|
+
//#region src/fair-queue/connection.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* Where a fair queue keeps its state: one Redis node, or a cluster. A cluster only works with a key
|
|
314
|
+
* producer that keeps every key a script touches in one slot, such as
|
|
315
|
+
* `TenantShardedFairQueueKeyProducer`. The cluster's key prefix goes in `clusterOptions.keyPrefix`.
|
|
316
|
+
*/
|
|
317
|
+
type FairQueueRedisOptions = RedisOptions | {
|
|
318
|
+
cluster: RedisClusterClientOptions;
|
|
319
|
+
};
|
|
320
|
+
declare function isClusterConnection(options: FairQueueRedisOptions): options is {
|
|
321
|
+
cluster: RedisClusterClientOptions;
|
|
322
|
+
};
|
|
323
|
+
declare function createFairQueueRedisClient(options: FairQueueRedisOptions): RedisClient;
|
|
324
|
+
declare function keyPrefixOf(options: FairQueueRedisOptions): string;
|
|
325
|
+
/**
|
|
326
|
+
* Every key matching `pattern` (which must include the key prefix), page by page. A cluster doesn't
|
|
327
|
+
* fan SCAN out to its nodes, so this scans each primary in turn.
|
|
328
|
+
*/
|
|
329
|
+
declare function scanKeys(client: RedisClient, pattern: string, count?: number): AsyncGenerator<string[]>;
|
|
330
|
+
//#endregion
|
|
293
331
|
//#region src/fair-queue/retry.d.ts
|
|
294
332
|
/**
|
|
295
333
|
* RetryStrategy interface for pluggable retry logic.
|
|
@@ -642,6 +680,21 @@ interface FairQueueKeyProducer {
|
|
|
642
680
|
extractTenantId(queueId: string): string;
|
|
643
681
|
/** Extract a specific group ID from a queue ID */
|
|
644
682
|
extractGroupId(groupName: string, queueId: string): string;
|
|
683
|
+
/**
|
|
684
|
+
* The shard a tenant's dispatch entry, queues and in-flight messages live on. When set, every
|
|
685
|
+
* component shards by tenant instead of by queue, so one shard holds all of a tenant's keys.
|
|
686
|
+
*/
|
|
687
|
+
tenantShard?(tenantId: string): number;
|
|
688
|
+
/** The number of shards `tenantShard` spreads tenants over. Required with `tenantShard`. */
|
|
689
|
+
readonly shardCount?: number;
|
|
690
|
+
/** The key holding one message's payload, for `separatePayloads`. */
|
|
691
|
+
payloadKey?(queueId: string, messageId: string): string;
|
|
692
|
+
/** The counter of a tenant's queued and in-flight payload bytes, for `separatePayloads`. */
|
|
693
|
+
tenantPayloadBytesKey?(tenantId: string): string;
|
|
694
|
+
/** The SCAN pattern matching one shard's concurrency sets for a group. */
|
|
695
|
+
concurrencyKeyPattern?(groupName: string, shardId: number): string;
|
|
696
|
+
/** The DRR scheduler's deficit hash. */
|
|
697
|
+
drrDeficitKey?(): string;
|
|
645
698
|
}
|
|
646
699
|
/**
|
|
647
700
|
* Worker queue configuration options.
|
|
@@ -684,11 +737,25 @@ interface CooloffOptions {
|
|
|
684
737
|
*/
|
|
685
738
|
interface FairQueueOptions<TPayloadSchema extends AnyZodSchema = z.ZodUnknown> {
|
|
686
739
|
/** Redis connection options */
|
|
687
|
-
redis:
|
|
740
|
+
redis: FairQueueRedisOptions;
|
|
688
741
|
/** Key producer for Redis keys */
|
|
689
742
|
keys: FairQueueKeyProducer;
|
|
690
743
|
/** Scheduler for fair queue selection */
|
|
691
744
|
scheduler: FairScheduler;
|
|
745
|
+
/**
|
|
746
|
+
* Keep each payload in its own key (`keys.payloadKey`), written once at enqueue and deleted at
|
|
747
|
+
* completion. Queue items and in-flight entries then hold only the message envelope, so claiming,
|
|
748
|
+
* releasing and retrying a message never rewrite its payload. `resolveWorkerQueue` receives the
|
|
749
|
+
* envelope without its payload. Enqueueing an id that is already queued or in flight is a no-op
|
|
750
|
+
* rather than a replace. Each tenant's payload bytes are counted while queued or in flight.
|
|
751
|
+
* Requires a key producer with `payloadKey` and `tenantPayloadBytesKey`.
|
|
752
|
+
*/
|
|
753
|
+
separatePayloads?: boolean;
|
|
754
|
+
/**
|
|
755
|
+
* The most payload bytes a tenant may have queued or in flight, with `separatePayloads`. An
|
|
756
|
+
* enqueue past it throws `TenantQueueFullError`. Absent, or a result of 0, means no limit.
|
|
757
|
+
*/
|
|
758
|
+
tenantPayloadBytesLimit?: (tenantId: string) => Promise<number> | number;
|
|
692
759
|
/** Zod schema for message payload validation */
|
|
693
760
|
payloadSchema?: TPayloadSchema;
|
|
694
761
|
/** Whether to validate payloads on enqueue (default: false) */
|
|
@@ -821,6 +888,11 @@ interface EnqueueOptions<TPayload = unknown> {
|
|
|
821
888
|
timestamp?: number;
|
|
822
889
|
/** Optional metadata for concurrency group extraction */
|
|
823
890
|
metadata?: Record<string, string>;
|
|
891
|
+
/**
|
|
892
|
+
* Enqueue past `tenantPayloadBytesLimit`. For a system's own follow-up work, which must not be
|
|
893
|
+
* refused because its tenant's incoming work filled the budget. Its bytes are still counted.
|
|
894
|
+
*/
|
|
895
|
+
ignorePayloadBytesLimit?: boolean;
|
|
824
896
|
}
|
|
825
897
|
/**
|
|
826
898
|
* Options for enqueueing multiple messages.
|
|
@@ -850,7 +922,7 @@ interface DRRSchedulerConfig {
|
|
|
850
922
|
/** Maximum queues to fetch from master queue (default: 1000) */
|
|
851
923
|
masterQueueLimit?: number;
|
|
852
924
|
/** Redis options for state storage */
|
|
853
|
-
redis:
|
|
925
|
+
redis: FairQueueRedisOptions;
|
|
854
926
|
/** Key producer */
|
|
855
927
|
keys: FairQueueKeyProducer;
|
|
856
928
|
/** Optional logger */
|
|
@@ -886,7 +958,7 @@ interface WeightedSchedulerBiases {
|
|
|
886
958
|
*/
|
|
887
959
|
interface WeightedSchedulerConfig {
|
|
888
960
|
/** Redis options */
|
|
889
|
-
redis:
|
|
961
|
+
redis: FairQueueRedisOptions;
|
|
890
962
|
/** Key producer */
|
|
891
963
|
keys: FairQueueKeyProducer;
|
|
892
964
|
/** Default tenant concurrency limit */
|
|
@@ -907,7 +979,7 @@ interface WeightedSchedulerConfig {
|
|
|
907
979
|
//#endregion
|
|
908
980
|
//#region src/fair-queue/concurrency.d.ts
|
|
909
981
|
interface ConcurrencyManagerOptions {
|
|
910
|
-
redis:
|
|
982
|
+
redis: FairQueueRedisOptions;
|
|
911
983
|
keys: FairQueueKeyProducer;
|
|
912
984
|
groups: ConcurrencyGroupConfig[];
|
|
913
985
|
logger?: {
|
|
@@ -965,7 +1037,10 @@ declare class ConcurrencyManager {
|
|
|
965
1037
|
* record can only be a leak; if the message is about to be re-claimed, reserve simply
|
|
966
1038
|
* re-adds the member.
|
|
967
1039
|
*
|
|
968
|
-
*
|
|
1040
|
+
* With a tenant-sharded key producer, each shard's sets are checked against that shard's
|
|
1041
|
+
* in-flight data only, so the check stays in one cluster slot.
|
|
1042
|
+
*
|
|
1043
|
+
* @param inflightDataKeys - The in-flight data hash keys for every shard, in shard order. The sweep
|
|
969
1044
|
* refuses to run when this is empty, since with nowhere to look for running messages
|
|
970
1045
|
* every member would look orphaned and all concurrency accounting would be erased.
|
|
971
1046
|
* @returns The message ids that were removed, and how many sets were checked
|
|
@@ -1089,10 +1164,62 @@ declare class CallbackFairQueueKeyProducer extends DefaultFairQueueKeyProducer {
|
|
|
1089
1164
|
extractTenantId(queueId: string): string;
|
|
1090
1165
|
extractGroupId(groupName: string, queueId: string): string;
|
|
1091
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Key producer for running a fair queue on a Redis cluster. Each tenant belongs to one shard,
|
|
1169
|
+
* `jumpHash(tenantId, shardCount)`, and every key of a shard carries the hash tag
|
|
1170
|
+
* `{prefix:shard}`, so a shard's queues, items, payloads, tenant indexes, dispatch index,
|
|
1171
|
+
* in-flight set and concurrency sets share a slot and every script stays single-slot.
|
|
1172
|
+
*
|
|
1173
|
+
* Concurrency groups must be keyed by tenant id. The shard count can't change without moving keys.
|
|
1174
|
+
*
|
|
1175
|
+
* Key structure (S = the tenant's shard):
|
|
1176
|
+
* - Dispatch index: {prefix:S}:dispatch
|
|
1177
|
+
* - Tenant queue index: {prefix:S}:tenantq:{tenantId}
|
|
1178
|
+
* - Queue: {prefix:S}:queue:{queueId}, items {prefix:S}:queue:{queueId}:items
|
|
1179
|
+
* - Payload: {prefix:S}:payload:{queueId}:{messageId}
|
|
1180
|
+
* - Payload bytes per tenant: {prefix:S}:payloadbytes:{tenantId}
|
|
1181
|
+
* - Concurrency: {prefix:S}:concurrency:{groupName}:{tenantId}
|
|
1182
|
+
* - In-flight: {prefix:S}:inflight, data {prefix:S}:inflight:data
|
|
1183
|
+
* - Dead letter queue: {prefix:S}:dlq:{tenantId}, data {prefix:S}:dlq:{tenantId}:data
|
|
1184
|
+
* - Legacy master queue: {prefix:S}:master
|
|
1185
|
+
* - Worker queue: {prefix}:worker:{consumerId} (its own slot)
|
|
1186
|
+
* - DRR deficits: {prefix}:drr:deficit (its own slot)
|
|
1187
|
+
*/
|
|
1188
|
+
declare class TenantShardedFairQueueKeyProducer implements FairQueueKeyProducer {
|
|
1189
|
+
#private;
|
|
1190
|
+
readonly shardCount: number;
|
|
1191
|
+
private readonly prefix;
|
|
1192
|
+
private readonly tenantExtractor;
|
|
1193
|
+
private readonly groupExtractor;
|
|
1194
|
+
constructor(options: {
|
|
1195
|
+
prefix: string;
|
|
1196
|
+
shardCount: number;
|
|
1197
|
+
extractTenantId: (queueId: string) => string;
|
|
1198
|
+
extractGroupId: (groupName: string, queueId: string) => string;
|
|
1199
|
+
});
|
|
1200
|
+
tenantShard(tenantId: string): number;
|
|
1201
|
+
masterQueueKey(shardId: number): string;
|
|
1202
|
+
queueKey(queueId: string): string;
|
|
1203
|
+
queueItemsKey(queueId: string): string;
|
|
1204
|
+
payloadKey(queueId: string, messageId: string): string;
|
|
1205
|
+
tenantPayloadBytesKey(tenantId: string): string;
|
|
1206
|
+
concurrencyKey(groupName: string, groupId: string): string;
|
|
1207
|
+
concurrencyKeyPattern(groupName: string, shardId: number): string;
|
|
1208
|
+
inflightKey(shardId: number): string;
|
|
1209
|
+
inflightDataKey(shardId: number): string;
|
|
1210
|
+
workerQueueKey(consumerId: string): string;
|
|
1211
|
+
deadLetterQueueKey(tenantId: string): string;
|
|
1212
|
+
deadLetterQueueDataKey(tenantId: string): string;
|
|
1213
|
+
dispatchKey(shardId: number): string;
|
|
1214
|
+
tenantQueueIndexKey(tenantId: string): string;
|
|
1215
|
+
drrDeficitKey(): string;
|
|
1216
|
+
extractTenantId(queueId: string): string;
|
|
1217
|
+
extractGroupId(groupName: string, queueId: string): string;
|
|
1218
|
+
}
|
|
1092
1219
|
//#endregion
|
|
1093
1220
|
//#region src/fair-queue/masterQueue.d.ts
|
|
1094
1221
|
interface MasterQueueOptions {
|
|
1095
|
-
redis:
|
|
1222
|
+
redis: FairQueueRedisOptions;
|
|
1096
1223
|
keys: FairQueueKeyProducer;
|
|
1097
1224
|
shardCount: number;
|
|
1098
1225
|
}
|
|
@@ -1355,7 +1482,7 @@ declare class WeightedScheduler extends BaseScheduler {
|
|
|
1355
1482
|
//#endregion
|
|
1356
1483
|
//#region src/fair-queue/schedulers/roundRobin.d.ts
|
|
1357
1484
|
interface RoundRobinSchedulerConfig {
|
|
1358
|
-
redis:
|
|
1485
|
+
redis: FairQueueRedisOptions;
|
|
1359
1486
|
keys: FairQueueKeyProducer;
|
|
1360
1487
|
/** Maximum queues to fetch from master queue per iteration */
|
|
1361
1488
|
masterQueueLimit?: number;
|
|
@@ -1423,6 +1550,7 @@ interface FairQueueMetrics {
|
|
|
1423
1550
|
dispatchLength: ObservableGauge;
|
|
1424
1551
|
inflightCount: ObservableGauge;
|
|
1425
1552
|
dlqLength: ObservableGauge;
|
|
1553
|
+
oldestMessageAge: ObservableGauge;
|
|
1426
1554
|
}
|
|
1427
1555
|
/**
|
|
1428
1556
|
* Options for creating FairQueue telemetry.
|
|
@@ -1509,6 +1637,7 @@ declare class FairQueueTelemetry {
|
|
|
1509
1637
|
getDispatchLength?: (shardId: number) => Promise<number>;
|
|
1510
1638
|
getInflightCount?: (shardId: number) => Promise<number>;
|
|
1511
1639
|
getDLQLength?: (tenantId: string) => Promise<number>;
|
|
1640
|
+
getOldestMessageAge?: (shardId: number) => Promise<number>;
|
|
1512
1641
|
shardCount?: number;
|
|
1513
1642
|
observedQueues?: string[];
|
|
1514
1643
|
observedTenants?: string[];
|
|
@@ -1642,7 +1771,7 @@ declare const noopTelemetry: FairQueueTelemetry;
|
|
|
1642
1771
|
//#endregion
|
|
1643
1772
|
//#region src/fair-queue/tenantDispatch.d.ts
|
|
1644
1773
|
interface TenantDispatchOptions {
|
|
1645
|
-
redis:
|
|
1774
|
+
redis: FairQueueRedisOptions;
|
|
1646
1775
|
keys: FairQueueKeyProducer;
|
|
1647
1776
|
shardCount: number;
|
|
1648
1777
|
}
|
|
@@ -1720,7 +1849,7 @@ declare class TenantDispatch {
|
|
|
1720
1849
|
//#endregion
|
|
1721
1850
|
//#region src/fair-queue/visibility.d.ts
|
|
1722
1851
|
interface VisibilityManagerOptions {
|
|
1723
|
-
redis:
|
|
1852
|
+
redis: FairQueueRedisOptions;
|
|
1724
1853
|
keys: FairQueueKeyProducer;
|
|
1725
1854
|
shardCount: number;
|
|
1726
1855
|
defaultTimeoutMs: number;
|
|
@@ -1875,7 +2004,7 @@ declare module "@internal/redis" {
|
|
|
1875
2004
|
//#endregion
|
|
1876
2005
|
//#region src/fair-queue/workerQueue.d.ts
|
|
1877
2006
|
interface WorkerQueueManagerOptions {
|
|
1878
|
-
redis:
|
|
2007
|
+
redis: FairQueueRedisOptions;
|
|
1879
2008
|
keys: FairQueueKeyProducer;
|
|
1880
2009
|
logger?: {
|
|
1881
2010
|
debug: (message: string, context?: Record<string, unknown>) => void;
|
|
@@ -1967,7 +2096,7 @@ declare class WorkerQueueManager {
|
|
|
1967
2096
|
* Register custom commands on an external Redis client.
|
|
1968
2097
|
* Use this when initializing FairQueue with worker queues.
|
|
1969
2098
|
*/
|
|
1970
|
-
registerCommands(redis:
|
|
2099
|
+
registerCommands(redis: RedisClient): void;
|
|
1971
2100
|
}
|
|
1972
2101
|
declare module "@internal/redis" {
|
|
1973
2102
|
interface RedisCommander<Context> {
|
|
@@ -1976,6 +2105,12 @@ declare module "@internal/redis" {
|
|
|
1976
2105
|
}
|
|
1977
2106
|
//#endregion
|
|
1978
2107
|
//#region src/fair-queue/index.d.ts
|
|
2108
|
+
/** An enqueue that would take a tenant past `tenantPayloadBytesLimit`. */
|
|
2109
|
+
declare class TenantQueueFullError extends Error {
|
|
2110
|
+
readonly tenantId: string;
|
|
2111
|
+
readonly limitBytes: number;
|
|
2112
|
+
constructor(tenantId: string, limitBytes: number);
|
|
2113
|
+
}
|
|
1979
2114
|
/**
|
|
1980
2115
|
* FairQueue is the main orchestrator for fair queue message routing.
|
|
1981
2116
|
*
|
|
@@ -2019,6 +2154,7 @@ declare class FairQueue<TPayloadSchema extends AnyZodSchema = z.ZodUnknown> {
|
|
|
2019
2154
|
private reconcileIntervalMs;
|
|
2020
2155
|
private workerQueueResolver;
|
|
2021
2156
|
private batchClaimSize;
|
|
2157
|
+
private separatePayloads;
|
|
2022
2158
|
private cooloffEnabled;
|
|
2023
2159
|
private cooloffThreshold;
|
|
2024
2160
|
private cooloffPeriodMs;
|
|
@@ -2116,6 +2252,11 @@ declare class FairQueue<TPayloadSchema extends AnyZodSchema = z.ZodUnknown> {
|
|
|
2116
2252
|
* Get total tenant count across dispatch shards plus any legacy queues still draining.
|
|
2117
2253
|
*/
|
|
2118
2254
|
getTotalQueueCount(): Promise<number>;
|
|
2255
|
+
/**
|
|
2256
|
+
* Get the age in ms of the oldest due message not yet completed in a shard, or 0 if none.
|
|
2257
|
+
* Claims don't refresh the index scores, so claimed messages count until their queue next completes or empties.
|
|
2258
|
+
*/
|
|
2259
|
+
getOldestMessageAge(shardId: number): Promise<number>;
|
|
2119
2260
|
/**
|
|
2120
2261
|
* Get total in-flight message count.
|
|
2121
2262
|
*/
|
|
@@ -2167,6 +2308,8 @@ declare class FairQueue<TPayloadSchema extends AnyZodSchema = z.ZodUnknown> {
|
|
|
2167
2308
|
* @param error - Optional error that caused the failure
|
|
2168
2309
|
*/
|
|
2169
2310
|
failMessage(messageId: string, queueId: string, error?: Error): Promise<void>;
|
|
2311
|
+
/** A tenant's queued and in-flight payload bytes, with `separatePayloads`. */
|
|
2312
|
+
getTenantPayloadBytes(tenantId: string): Promise<number>;
|
|
2170
2313
|
}
|
|
2171
2314
|
declare module "@internal/redis" {
|
|
2172
2315
|
interface RedisCommander<Context> {
|
|
@@ -2176,6 +2319,8 @@ declare module "@internal/redis" {
|
|
|
2176
2319
|
enqueueMessageAtomicV2(queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, messageId: string, timestamp: string, payload: string, tenantId: string): Promise<number>;
|
|
2177
2320
|
enqueueBatchAtomicV2(queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, tenantId: string, ...args: string[]): Promise<number>;
|
|
2178
2321
|
updateDispatchIndexes(queueKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, tenantId: string): Promise<number>;
|
|
2322
|
+
enqueueMessageSeparatePayload(queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, payloadKey: string, inflightKey: string, bytesKey: string, queueId: string, messageId: string, timestamp: string, envelope: string, tenantId: string, payload: string, inflightMember: string, limit: string): Promise<number>;
|
|
2323
|
+
completeSeparatePayload(inflightKey: string, inflightDataKey: string, payloadKey: string, bytesKey: string, inflightMember: string, messageId: string): Promise<number>;
|
|
2179
2324
|
}
|
|
2180
2325
|
}
|
|
2181
2326
|
//#endregion
|
|
@@ -2432,4 +2577,4 @@ declare class MollifierDrainer<TPayload = unknown> {
|
|
|
2432
2577
|
private processEntry;
|
|
2433
2578
|
}
|
|
2434
2579
|
//#endregion
|
|
2435
|
-
export { type AcceptResult, AnyMessageCatalog, AnyQueueItem, BaseScheduler, BatchConfig, BatchedSpanManager, BatchedSpanManagerOptions, type BufferEntry, BufferEntryError, BufferEntrySchema, BufferEntryStatus, CallbackFairQueueKeyProducer, type CasSetMetadataResult, ClaimResult, ConcurrencyCheckResult, ConcurrencyGroupConfig, ConcurrencyManager, ConcurrencyManagerOptions, ConcurrencyState, ConsumerLoopState, CooloffOptions, CronSchema, CustomRetry, DRRScheduler, DRRSchedulerConfig, DeadLetterMessage, DefaultFairQueueKeyProducer, DispatchSchedulerContext, type DrainResult, EnqueueBatchOptions, EnqueueOptions, ExponentialBackoffRetry, FairQueue, FairQueueAttributes, FairQueueKeyProducer, FairQueueMetrics, FairQueueOptions, FairQueueTelemetry, FairScheduler, FixedDelayRetry, GlobalRateLimiter, type IdempotencyClaimResult, type IdempotencyLookupInput, ImmediateRetry, InFlightMessage, JobHandler, JobHandlerParams, LinearBackoffRetry, MasterQueue, MasterQueueOptions, MessageCatalogKey, MessageCatalogSchema, MessageCatalogValue, MessageHandler, MessageHandlerContext, MessagingAttributes, MollifierBuffer, type MollifierBufferOptions, MollifierDrainer, type MollifierDrainerHandler, type MollifierDrainerOptions, type MollifierDrainerTerminalFailureCause, type MollifierDrainerTerminalFailureHandler, type MutateSnapshotResult, NoRetry, NoopScheduler, QueueCooloffState, QueueDescriptor, QueueItem, QueueMessage, QueueWithScore, ReclaimedMessageInfo, RetryOptions, RetryStrategy, RoundRobinScheduler, SchedulerContext, SimpleQueue, type SnapshotPatch, StoredMessage, TelemetryOptions, TenantDispatch, TenantDispatchOptions, TenantQueues, TenantWithScore, VisibilityManager, VisibilityManagerOptions, WeightedScheduler, WeightedSchedulerBiases, WeightedSchedulerConfig, Worker, WorkerCatalog, WorkerConcurrencyOptions, WorkerQueueManager, WorkerQueueManagerOptions, WorkerQueueOptions, createDefaultRetryStrategy, defaultRetryOptions, deserialiseSnapshot, idempotencyLookupKeyFor, isAbortError, makeIdempotencyClaimKey, noopTelemetry, serialiseSnapshot };
|
|
2580
|
+
export { type AcceptResult, AnyMessageCatalog, AnyQueueItem, BaseScheduler, BatchConfig, BatchedSpanManager, BatchedSpanManagerOptions, type BufferEntry, BufferEntryError, BufferEntrySchema, BufferEntryStatus, CallbackFairQueueKeyProducer, type CasSetMetadataResult, ClaimResult, ConcurrencyCheckResult, ConcurrencyGroupConfig, ConcurrencyManager, ConcurrencyManagerOptions, ConcurrencyState, ConsumerLoopState, CooloffOptions, CronSchema, CustomRetry, DRRScheduler, DRRSchedulerConfig, DeadLetterMessage, DefaultFairQueueKeyProducer, DispatchSchedulerContext, type DrainResult, EnqueueBatchOptions, EnqueueOptions, ExponentialBackoffRetry, FairQueue, FairQueueAttributes, FairQueueKeyProducer, FairQueueMetrics, FairQueueOptions, FairQueueRedisOptions, FairQueueTelemetry, FairScheduler, FixedDelayRetry, GlobalRateLimiter, type IdempotencyClaimResult, type IdempotencyLookupInput, ImmediateRetry, InFlightMessage, JobHandler, JobHandlerParams, LinearBackoffRetry, MasterQueue, MasterQueueOptions, MessageCatalogKey, MessageCatalogSchema, MessageCatalogValue, MessageHandler, MessageHandlerContext, MessagingAttributes, MollifierBuffer, type MollifierBufferOptions, MollifierDrainer, type MollifierDrainerHandler, type MollifierDrainerOptions, type MollifierDrainerTerminalFailureCause, type MollifierDrainerTerminalFailureHandler, type MutateSnapshotResult, NoRetry, NoopScheduler, QueueCooloffState, QueueDescriptor, QueueItem, QueueMessage, QueueWithScore, ReclaimedMessageInfo, RetryOptions, RetryStrategy, RoundRobinScheduler, SchedulerContext, SimpleQueue, type SnapshotPatch, StoredMessage, TelemetryOptions, TenantDispatch, TenantDispatchOptions, TenantQueueFullError, TenantQueues, TenantShardedFairQueueKeyProducer, TenantWithScore, VisibilityManager, VisibilityManagerOptions, WeightedScheduler, WeightedSchedulerBiases, WeightedSchedulerConfig, Worker, WorkerCatalog, WorkerConcurrencyOptions, WorkerQueueManager, WorkerQueueManagerOptions, WorkerQueueOptions, createDefaultRetryStrategy, createFairQueueRedisClient, defaultRetryOptions, deserialiseSnapshot, idempotencyLookupKeyFor, isAbortError, isClusterConnection, keyPrefixOf, makeIdempotencyClaimKey, noopTelemetry, scanKeys, serialiseSnapshot };
|