@trigger.dev/redis-worker 4.4.1 → 4.4.3
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 +894 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +195 -14
- package/dist/index.d.ts +195 -14
- package/dist/index.js +894 -145
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -97,6 +97,10 @@ declare const CronSchema: z.ZodObject<{
|
|
|
97
97
|
lastTimestamp?: number | undefined;
|
|
98
98
|
}>;
|
|
99
99
|
type CronSchema = z.infer<typeof CronSchema>;
|
|
100
|
+
type BatchConfig = {
|
|
101
|
+
maxSize: number;
|
|
102
|
+
maxWaitMs: number;
|
|
103
|
+
};
|
|
100
104
|
type WorkerCatalog = {
|
|
101
105
|
[key: string]: {
|
|
102
106
|
schema: z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion<any, any>;
|
|
@@ -106,6 +110,8 @@ type WorkerCatalog = {
|
|
|
106
110
|
jitterInMs?: number;
|
|
107
111
|
/** Defaults to true. If false, errors will not be logged. */
|
|
108
112
|
logErrors?: boolean;
|
|
113
|
+
/** When set, items are accumulated and delivered in batches to the handler. */
|
|
114
|
+
batch?: BatchConfig;
|
|
109
115
|
};
|
|
110
116
|
};
|
|
111
117
|
type QueueCatalogFromWorkerCatalog<Catalog extends WorkerCatalog> = {
|
|
@@ -119,6 +125,9 @@ type JobHandlerParams<Catalog extends WorkerCatalog, K extends keyof Catalog> =
|
|
|
119
125
|
deduplicationKey?: string;
|
|
120
126
|
};
|
|
121
127
|
type JobHandler<Catalog extends WorkerCatalog, K extends keyof Catalog> = (params: JobHandlerParams<Catalog, K>) => Promise<void>;
|
|
128
|
+
type JobHandlerFor<Catalog extends WorkerCatalog, K extends keyof Catalog> = Catalog[K] extends {
|
|
129
|
+
batch: BatchConfig;
|
|
130
|
+
} ? (items: Array<JobHandlerParams<Catalog, K>>) => Promise<void> : (params: JobHandlerParams<Catalog, K>) => Promise<void>;
|
|
122
131
|
type WorkerConcurrencyOptions = {
|
|
123
132
|
workers?: number;
|
|
124
133
|
tasksPerWorker?: number;
|
|
@@ -129,7 +138,7 @@ type WorkerOptions<TCatalog extends WorkerCatalog> = {
|
|
|
129
138
|
redisOptions: RedisOptions;
|
|
130
139
|
catalog: TCatalog;
|
|
131
140
|
jobs: {
|
|
132
|
-
[K in keyof TCatalog]:
|
|
141
|
+
[K in keyof TCatalog]: JobHandlerFor<TCatalog, K>;
|
|
133
142
|
};
|
|
134
143
|
concurrency?: WorkerConcurrencyOptions;
|
|
135
144
|
pollIntervalMs?: number;
|
|
@@ -154,6 +163,7 @@ declare class Worker<TCatalog extends WorkerCatalog> {
|
|
|
154
163
|
private concurrency;
|
|
155
164
|
private shutdownTimeoutMs;
|
|
156
165
|
private limiters;
|
|
166
|
+
private batchAccumulators;
|
|
157
167
|
constructor(options: WorkerOptions<TCatalog>);
|
|
158
168
|
start(): this;
|
|
159
169
|
/**
|
|
@@ -206,11 +216,45 @@ declare class Worker<TCatalog extends WorkerCatalog> {
|
|
|
206
216
|
cancel(cancellationKey: string): Promise<void>;
|
|
207
217
|
ack(id: string): Promise<void>;
|
|
208
218
|
getJob(id: string): Promise<QueueItem<QueueCatalogFromWorkerCatalog<TCatalog>> | null>;
|
|
219
|
+
/**
|
|
220
|
+
* Returns true if the given job type has batch config in the catalog.
|
|
221
|
+
*/
|
|
222
|
+
private isBatchJob;
|
|
223
|
+
/**
|
|
224
|
+
* Returns the batch config for a job type, or undefined if not batch-enabled.
|
|
225
|
+
*/
|
|
226
|
+
private getBatchConfig;
|
|
227
|
+
/**
|
|
228
|
+
* The max dequeue count: the largest batch maxSize across catalog entries,
|
|
229
|
+
* falling back to tasksPerWorker for non-batch catalogs.
|
|
230
|
+
*/
|
|
231
|
+
private get maxDequeueCount();
|
|
209
232
|
/**
|
|
210
233
|
* The main loop that each worker runs. It repeatedly polls for items,
|
|
211
234
|
* processes them, and then waits before the next iteration.
|
|
212
235
|
*/
|
|
213
236
|
private runWorkerLoop;
|
|
237
|
+
/**
|
|
238
|
+
* Adds an item to the batch accumulator for its job type.
|
|
239
|
+
*/
|
|
240
|
+
private addToAccumulator;
|
|
241
|
+
/**
|
|
242
|
+
* Flushes any batch accumulators that have exceeded their maxWaitMs.
|
|
243
|
+
*/
|
|
244
|
+
private flushTimedOutBatches;
|
|
245
|
+
/**
|
|
246
|
+
* Flushes all batch accumulators (used during shutdown).
|
|
247
|
+
*/
|
|
248
|
+
private flushAllBatches;
|
|
249
|
+
/**
|
|
250
|
+
* Flushes the batch accumulator for a specific job type.
|
|
251
|
+
* Removes items from the accumulator and submits them to the limiter as a single batch.
|
|
252
|
+
*/
|
|
253
|
+
private flushBatch;
|
|
254
|
+
/**
|
|
255
|
+
* Processes a batch of items for a batch-enabled job type.
|
|
256
|
+
*/
|
|
257
|
+
private processBatch;
|
|
214
258
|
/**
|
|
215
259
|
* Processes a single item.
|
|
216
260
|
*/
|
|
@@ -485,6 +529,13 @@ interface SchedulerContext {
|
|
|
485
529
|
/** Get queue descriptor by ID */
|
|
486
530
|
getQueueDescriptor(queueId: string): QueueDescriptor;
|
|
487
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Extended context for two-level dispatch scheduling.
|
|
534
|
+
*/
|
|
535
|
+
interface DispatchSchedulerContext extends SchedulerContext {
|
|
536
|
+
/** Get queues for a specific tenant from the per-tenant queue index (Level 2) */
|
|
537
|
+
getQueuesForTenant(tenantId: string, limit?: number): Promise<QueueWithScore[]>;
|
|
538
|
+
}
|
|
488
539
|
/**
|
|
489
540
|
* Pluggable scheduler interface for fair queue selection.
|
|
490
541
|
*/
|
|
@@ -499,6 +550,13 @@ interface FairScheduler {
|
|
|
499
550
|
* @returns Queues grouped by tenant in priority order
|
|
500
551
|
*/
|
|
501
552
|
selectQueues(masterQueueShard: string, consumerId: string, context: SchedulerContext): Promise<TenantQueues[]>;
|
|
553
|
+
/**
|
|
554
|
+
* Select queues using the two-level tenant dispatch index.
|
|
555
|
+
* Level 1: reads tenantIds from dispatch shard.
|
|
556
|
+
* Level 2: reads queueIds from per-tenant index.
|
|
557
|
+
* Optional - falls back to selectQueues with flat queue list if not implemented.
|
|
558
|
+
*/
|
|
559
|
+
selectQueuesFromDispatch?(dispatchShardKey: string, consumerId: string, context: DispatchSchedulerContext): Promise<TenantQueues[]>;
|
|
502
560
|
/**
|
|
503
561
|
* Called after processing a message to update scheduler state.
|
|
504
562
|
* Optional - not all schedulers need to track state.
|
|
@@ -566,6 +624,10 @@ interface FairQueueKeyProducer {
|
|
|
566
624
|
deadLetterQueueKey(tenantId: string): string;
|
|
567
625
|
/** Get the dead letter queue data hash key for a tenant */
|
|
568
626
|
deadLetterQueueDataKey(tenantId: string): string;
|
|
627
|
+
/** Get the dispatch index key for a shard (Level 1: tenantIds with capacity) */
|
|
628
|
+
dispatchKey(shardId: number): string;
|
|
629
|
+
/** Get the per-tenant queue index key (Level 2: queueIds for a tenant) */
|
|
630
|
+
tenantQueueIndexKey(tenantId: string): string;
|
|
569
631
|
/** Extract tenant ID from a queue ID */
|
|
570
632
|
extractTenantId(queueId: string): string;
|
|
571
633
|
/** Extract a specific group ID from a queue ID */
|
|
@@ -660,8 +722,22 @@ interface FairQueueOptions<TPayloadSchema extends z.ZodTypeAny = z.ZodUnknown> {
|
|
|
660
722
|
meter?: Meter;
|
|
661
723
|
/** Name for metrics/tracing (default: "fairqueue") */
|
|
662
724
|
name?: string;
|
|
663
|
-
/**
|
|
664
|
-
|
|
725
|
+
/**
|
|
726
|
+
* Maximum number of items allowed in a worker queue before claiming pauses.
|
|
727
|
+
* When set, the claim phase checks worker queue depth and skips claiming if
|
|
728
|
+
* the queue is at or above this limit. This prevents unbounded worker queue
|
|
729
|
+
* growth which could cause visibility timeouts (claimed messages have a
|
|
730
|
+
* visibility timeout that ticks while they sit in the worker queue).
|
|
731
|
+
* Requires `workerQueueDepthCheckId` to know which queue to check.
|
|
732
|
+
* Disabled by default (0 = no limit).
|
|
733
|
+
*/
|
|
734
|
+
workerQueueMaxDepth?: number;
|
|
735
|
+
/**
|
|
736
|
+
* The worker queue ID to check depth against when workerQueueMaxDepth is set.
|
|
737
|
+
* Required when workerQueueMaxDepth > 0 and the system uses a single shared worker queue.
|
|
738
|
+
* If not set, depth checking is disabled even if workerQueueMaxDepth is set.
|
|
739
|
+
*/
|
|
740
|
+
workerQueueDepthCheckId?: string;
|
|
665
741
|
}
|
|
666
742
|
/**
|
|
667
743
|
* Context passed to the message handler.
|
|
@@ -822,7 +898,9 @@ interface WeightedSchedulerConfig {
|
|
|
822
898
|
* Uses a configurable prefix and standard key structure.
|
|
823
899
|
*
|
|
824
900
|
* Key structure:
|
|
825
|
-
* - Master queue: {prefix}:master:{shardId}
|
|
901
|
+
* - Master queue: {prefix}:master:{shardId} (legacy, drain-only)
|
|
902
|
+
* - Dispatch index: {prefix}:dispatch:{shardId} (Level 1: tenantIds)
|
|
903
|
+
* - Tenant queue index: {prefix}:tenantq:{tenantId} (Level 2: queueIds)
|
|
826
904
|
* - Queue: {prefix}:queue:{queueId}
|
|
827
905
|
* - Queue items: {prefix}:queue:{queueId}:items
|
|
828
906
|
* - Concurrency: {prefix}:concurrency:{groupName}:{groupId}
|
|
@@ -845,6 +923,8 @@ declare class DefaultFairQueueKeyProducer implements FairQueueKeyProducer {
|
|
|
845
923
|
inflightKey(shardId: number): string;
|
|
846
924
|
inflightDataKey(shardId: number): string;
|
|
847
925
|
workerQueueKey(consumerId: string): string;
|
|
926
|
+
dispatchKey(shardId: number): string;
|
|
927
|
+
tenantQueueIndexKey(tenantId: string): string;
|
|
848
928
|
deadLetterQueueKey(tenantId: string): string;
|
|
849
929
|
deadLetterQueueDataKey(tenantId: string): string;
|
|
850
930
|
/**
|
|
@@ -1148,10 +1228,12 @@ declare class VisibilityManager {
|
|
|
1148
1228
|
* @param queueId - The queue ID
|
|
1149
1229
|
* @param queueKey - The Redis key for the queue
|
|
1150
1230
|
* @param queueItemsKey - The Redis key for the queue items hash
|
|
1151
|
-
* @param
|
|
1231
|
+
* @param tenantQueueIndexKey - The Redis key for the tenant queue index (Level 2)
|
|
1232
|
+
* @param dispatchKey - The Redis key for the dispatch index (Level 1)
|
|
1233
|
+
* @param tenantId - The tenant ID
|
|
1152
1234
|
* @param score - Optional score for the message (defaults to now)
|
|
1153
1235
|
*/
|
|
1154
|
-
release<TPayload = unknown>(messageId: string, queueId: string, queueKey: string, queueItemsKey: string,
|
|
1236
|
+
release<TPayload = unknown>(messageId: string, queueId: string, queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, tenantId: string, score?: number, updatedData?: string): Promise<void>;
|
|
1155
1237
|
/**
|
|
1156
1238
|
* Release multiple messages back to their queue in a single operation.
|
|
1157
1239
|
* Used when processing fails or consumer wants to retry later.
|
|
@@ -1161,12 +1243,14 @@ declare class VisibilityManager {
|
|
|
1161
1243
|
* @param queueId - The queue ID
|
|
1162
1244
|
* @param queueKey - The Redis key for the queue
|
|
1163
1245
|
* @param queueItemsKey - The Redis key for the queue items hash
|
|
1164
|
-
* @param
|
|
1246
|
+
* @param tenantQueueIndexKey - The Redis key for the tenant queue index (Level 2)
|
|
1247
|
+
* @param dispatchKey - The Redis key for the dispatch index (Level 1)
|
|
1248
|
+
* @param tenantId - The tenant ID
|
|
1165
1249
|
* @param score - Optional score for the messages (defaults to now)
|
|
1166
1250
|
*/
|
|
1167
1251
|
releaseBatch(messages: Array<{
|
|
1168
1252
|
messageId: string;
|
|
1169
|
-
}>, queueId: string, queueKey: string, queueItemsKey: string,
|
|
1253
|
+
}>, queueId: string, queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, tenantId: string, score?: number): Promise<void>;
|
|
1170
1254
|
/**
|
|
1171
1255
|
* Reclaim timed-out messages from a shard.
|
|
1172
1256
|
* Returns messages to their original queues.
|
|
@@ -1178,7 +1262,9 @@ declare class VisibilityManager {
|
|
|
1178
1262
|
reclaimTimedOut(shardId: number, getQueueKeys: (queueId: string) => {
|
|
1179
1263
|
queueKey: string;
|
|
1180
1264
|
queueItemsKey: string;
|
|
1181
|
-
|
|
1265
|
+
tenantQueueIndexKey: string;
|
|
1266
|
+
dispatchKey: string;
|
|
1267
|
+
tenantId: string;
|
|
1182
1268
|
}): Promise<ReclaimedMessageInfo[]>;
|
|
1183
1269
|
/**
|
|
1184
1270
|
* Get all in-flight messages for a shard.
|
|
@@ -1205,8 +1291,8 @@ declare module "@internal/redis" {
|
|
|
1205
1291
|
interface RedisCommander<Context> {
|
|
1206
1292
|
claimMessage(queueKey: string, queueItemsKey: string, inflightKey: string, inflightDataKey: string, queueId: string, consumerId: string, deadline: string): Promise<[string, string] | null>;
|
|
1207
1293
|
claimMessageBatch(queueKey: string, queueItemsKey: string, inflightKey: string, inflightDataKey: string, queueId: string, deadline: string, maxCount: string): Promise<string[]>;
|
|
1208
|
-
releaseMessage(inflightKey: string, inflightDataKey: string, queueKey: string, queueItemsKey: string,
|
|
1209
|
-
releaseMessageBatch(inflightKey: string, inflightDataKey: string, queueKey: string, queueItemsKey: string,
|
|
1294
|
+
releaseMessage(inflightKey: string, inflightDataKey: string, queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, member: string, messageId: string, score: string, queueId: string, updatedData: string, tenantId: string): Promise<number>;
|
|
1295
|
+
releaseMessageBatch(inflightKey: string, inflightDataKey: string, queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, score: string, queueId: string, tenantId: string, ...membersAndMessageIds: string[]): Promise<number>;
|
|
1210
1296
|
heartbeatMessage(inflightKey: string, member: string, newDeadline: string): Promise<number>;
|
|
1211
1297
|
}
|
|
1212
1298
|
}
|
|
@@ -1403,6 +1489,17 @@ declare class DRRScheduler extends BaseScheduler {
|
|
|
1403
1489
|
* 6. Order tenants by deficit (highest first for fairness)
|
|
1404
1490
|
*/
|
|
1405
1491
|
selectQueues(masterQueueShard: string, consumerId: string, context: SchedulerContext): Promise<TenantQueues[]>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Select queues using the two-level tenant dispatch index.
|
|
1494
|
+
*
|
|
1495
|
+
* Algorithm:
|
|
1496
|
+
* 1. ZRANGEBYSCORE on dispatch index (gets only tenants with queues - much smaller)
|
|
1497
|
+
* 2. Add quantum to each tenant's deficit (atomically)
|
|
1498
|
+
* 3. Check capacity as safety net (dispatch should only have tenants with capacity)
|
|
1499
|
+
* 4. Select tenants with deficit >= 1, sorted by deficit (highest first)
|
|
1500
|
+
* 5. For each tenant, fetch their queues from Level 2 index
|
|
1501
|
+
*/
|
|
1502
|
+
selectQueuesFromDispatch(dispatchShardKey: string, consumerId: string, context: DispatchSchedulerContext): Promise<TenantQueues[]>;
|
|
1406
1503
|
/**
|
|
1407
1504
|
* Record that a message was processed from a tenant.
|
|
1408
1505
|
* Decrements the tenant's deficit.
|
|
@@ -1531,6 +1628,7 @@ interface FairQueueMetrics {
|
|
|
1531
1628
|
queueTime: Histogram;
|
|
1532
1629
|
queueLength: ObservableGauge;
|
|
1533
1630
|
masterQueueLength: ObservableGauge;
|
|
1631
|
+
dispatchLength: ObservableGauge;
|
|
1534
1632
|
inflightCount: ObservableGauge;
|
|
1535
1633
|
dlqLength: ObservableGauge;
|
|
1536
1634
|
}
|
|
@@ -1616,6 +1714,7 @@ declare class FairQueueTelemetry {
|
|
|
1616
1714
|
registerGaugeCallbacks(callbacks: {
|
|
1617
1715
|
getQueueLength?: (queueId: string) => Promise<number>;
|
|
1618
1716
|
getMasterQueueLength?: (shardId: number) => Promise<number>;
|
|
1717
|
+
getDispatchLength?: (shardId: number) => Promise<number>;
|
|
1619
1718
|
getInflightCount?: (shardId: number) => Promise<number>;
|
|
1620
1719
|
getDLQLength?: (tenantId: string) => Promise<number>;
|
|
1621
1720
|
shardCount?: number;
|
|
@@ -1749,6 +1848,83 @@ declare class BatchedSpanManager {
|
|
|
1749
1848
|
*/
|
|
1750
1849
|
declare const noopTelemetry: FairQueueTelemetry;
|
|
1751
1850
|
|
|
1851
|
+
interface TenantDispatchOptions {
|
|
1852
|
+
redis: RedisOptions;
|
|
1853
|
+
keys: FairQueueKeyProducer;
|
|
1854
|
+
shardCount: number;
|
|
1855
|
+
}
|
|
1856
|
+
interface TenantWithScore {
|
|
1857
|
+
tenantId: string;
|
|
1858
|
+
score: number;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* TenantDispatch manages the two-level tenant dispatch index.
|
|
1862
|
+
*
|
|
1863
|
+
* Level 1 - Dispatch Index (per shard):
|
|
1864
|
+
* Key: {prefix}:dispatch:{shardId}
|
|
1865
|
+
* ZSET of tenantIds scored by oldest message timestamp across their queues.
|
|
1866
|
+
* Only tenants with queues containing messages appear here.
|
|
1867
|
+
*
|
|
1868
|
+
* Level 2 - Per-Tenant Queue Index:
|
|
1869
|
+
* Key: {prefix}:tenantq:{tenantId}
|
|
1870
|
+
* ZSET of queueIds scored by oldest message timestamp in that queue.
|
|
1871
|
+
*
|
|
1872
|
+
* This replaces the flat master queue for new enqueues, isolating each tenant's
|
|
1873
|
+
* queue backlog so the scheduler iterates tenants (not queues) at Level 1.
|
|
1874
|
+
*/
|
|
1875
|
+
declare class TenantDispatch {
|
|
1876
|
+
private options;
|
|
1877
|
+
private redis;
|
|
1878
|
+
private keys;
|
|
1879
|
+
private shardCount;
|
|
1880
|
+
constructor(options: TenantDispatchOptions);
|
|
1881
|
+
/**
|
|
1882
|
+
* Get the dispatch shard ID for a tenant.
|
|
1883
|
+
* Uses jump consistent hash on the tenant ID so each tenant
|
|
1884
|
+
* always maps to exactly one dispatch shard.
|
|
1885
|
+
*/
|
|
1886
|
+
getShardForTenant(tenantId: string): number;
|
|
1887
|
+
/**
|
|
1888
|
+
* Get eligible tenants from a dispatch shard (Level 1).
|
|
1889
|
+
* Returns tenants ordered by oldest message (lowest score first).
|
|
1890
|
+
*/
|
|
1891
|
+
getTenantsFromShard(shardId: number, limit?: number, maxScore?: number): Promise<TenantWithScore[]>;
|
|
1892
|
+
/**
|
|
1893
|
+
* Get queues for a specific tenant (Level 2).
|
|
1894
|
+
* Returns queues ordered by oldest message (lowest score first).
|
|
1895
|
+
*/
|
|
1896
|
+
getQueuesForTenant(tenantId: string, limit?: number, maxScore?: number): Promise<QueueWithScore[]>;
|
|
1897
|
+
/**
|
|
1898
|
+
* Get the number of tenants in a dispatch shard.
|
|
1899
|
+
*/
|
|
1900
|
+
getShardTenantCount(shardId: number): Promise<number>;
|
|
1901
|
+
/**
|
|
1902
|
+
* Get total tenant count across all dispatch shards.
|
|
1903
|
+
* Note: tenants may appear in multiple shards, so this may overcount.
|
|
1904
|
+
*/
|
|
1905
|
+
getTotalTenantCount(): Promise<number>;
|
|
1906
|
+
/**
|
|
1907
|
+
* Get the number of queues for a tenant.
|
|
1908
|
+
*/
|
|
1909
|
+
getTenantQueueCount(tenantId: string): Promise<number>;
|
|
1910
|
+
/**
|
|
1911
|
+
* Remove a tenant from a specific dispatch shard.
|
|
1912
|
+
*/
|
|
1913
|
+
removeTenantFromShard(shardId: number, tenantId: string): Promise<void>;
|
|
1914
|
+
/**
|
|
1915
|
+
* Add a tenant to a dispatch shard with the given score.
|
|
1916
|
+
*/
|
|
1917
|
+
addTenantToShard(shardId: number, tenantId: string, score: number): Promise<void>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Remove a queue from a tenant's queue index.
|
|
1920
|
+
*/
|
|
1921
|
+
removeQueueFromTenant(tenantId: string, queueId: string): Promise<void>;
|
|
1922
|
+
/**
|
|
1923
|
+
* Close the Redis connection.
|
|
1924
|
+
*/
|
|
1925
|
+
close(): Promise<void>;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1752
1928
|
/**
|
|
1753
1929
|
* FairQueue is the main orchestrator for fair queue message routing.
|
|
1754
1930
|
*
|
|
@@ -1796,7 +1972,8 @@ declare class FairQueue<TPayloadSchema extends z.ZodTypeAny = z.ZodUnknown> {
|
|
|
1796
1972
|
private cooloffPeriodMs;
|
|
1797
1973
|
private maxCooloffStatesSize;
|
|
1798
1974
|
private queueCooloffStates;
|
|
1799
|
-
private
|
|
1975
|
+
private workerQueueMaxDepth;
|
|
1976
|
+
private workerQueueDepthCheckId?;
|
|
1800
1977
|
private consumerTraceMaxIterations;
|
|
1801
1978
|
private consumerTraceTimeoutSeconds;
|
|
1802
1979
|
private batchedSpanManager;
|
|
@@ -1805,6 +1982,7 @@ declare class FairQueue<TPayloadSchema extends z.ZodTypeAny = z.ZodUnknown> {
|
|
|
1805
1982
|
private masterQueueConsumerLoops;
|
|
1806
1983
|
private reclaimLoop?;
|
|
1807
1984
|
private queueDescriptorCache;
|
|
1985
|
+
private tenantDispatch;
|
|
1808
1986
|
constructor(options: FairQueueOptions<TPayloadSchema>);
|
|
1809
1987
|
/**
|
|
1810
1988
|
* Register observable gauge callbacks for telemetry.
|
|
@@ -1882,7 +2060,7 @@ declare class FairQueue<TPayloadSchema extends z.ZodTypeAny = z.ZodUnknown> {
|
|
|
1882
2060
|
*/
|
|
1883
2061
|
getQueueLength(queueId: string): Promise<number>;
|
|
1884
2062
|
/**
|
|
1885
|
-
* Get total
|
|
2063
|
+
* Get total tenant count across dispatch shards plus any legacy queues still draining.
|
|
1886
2064
|
*/
|
|
1887
2065
|
getTotalQueueCount(): Promise<number>;
|
|
1888
2066
|
/**
|
|
@@ -1942,7 +2120,10 @@ declare module "@internal/redis" {
|
|
|
1942
2120
|
enqueueMessageAtomic(queueKey: string, queueItemsKey: string, masterQueueKey: string, queueId: string, messageId: string, timestamp: string, payload: string): Promise<number>;
|
|
1943
2121
|
enqueueBatchAtomic(queueKey: string, queueItemsKey: string, masterQueueKey: string, queueId: string, ...args: string[]): Promise<number>;
|
|
1944
2122
|
updateMasterQueueIfEmpty(masterQueueKey: string, queueKey: string, queueId: string): Promise<number>;
|
|
2123
|
+
enqueueMessageAtomicV2(queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, messageId: string, timestamp: string, payload: string, tenantId: string): Promise<number>;
|
|
2124
|
+
enqueueBatchAtomicV2(queueKey: string, queueItemsKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, tenantId: string, ...args: string[]): Promise<number>;
|
|
2125
|
+
updateDispatchIndexes(queueKey: string, tenantQueueIndexKey: string, dispatchKey: string, queueId: string, tenantId: string): Promise<number>;
|
|
1945
2126
|
}
|
|
1946
2127
|
}
|
|
1947
2128
|
|
|
1948
|
-
export { type AnyMessageCatalog, type AnyQueueItem, BaseScheduler, BatchedSpanManager, type BatchedSpanManagerOptions, CallbackFairQueueKeyProducer, type ClaimResult, type ConcurrencyCheckResult, type ConcurrencyGroupConfig, ConcurrencyManager, type ConcurrencyManagerOptions, type ConcurrencyState, type ConsumerLoopState, type CooloffOptions, CronSchema, CustomRetry, DRRScheduler, type DRRSchedulerConfig, type DeadLetterMessage, DefaultFairQueueKeyProducer, type EnqueueBatchOptions, type EnqueueOptions, ExponentialBackoffRetry, FairQueue, FairQueueAttributes, type FairQueueKeyProducer, type FairQueueMetrics, type FairQueueOptions, FairQueueTelemetry, type FairScheduler, FixedDelayRetry, type GlobalRateLimiter, ImmediateRetry, type InFlightMessage, type JobHandler, type JobHandlerParams, LinearBackoffRetry, MasterQueue, type MasterQueueOptions, type MessageCatalogKey, type MessageCatalogSchema, type MessageCatalogValue, type MessageHandler, type MessageHandlerContext, MessagingAttributes, NoRetry, NoopScheduler, type QueueCooloffState, type QueueDescriptor, type QueueItem, type QueueMessage, type QueueWithScore, type ReclaimedMessageInfo, type RetryOptions, type RetryStrategy, RoundRobinScheduler, type SchedulerContext, SimpleQueue, type StoredMessage, type TelemetryOptions, type TenantQueues, VisibilityManager, type VisibilityManagerOptions, WeightedScheduler, type WeightedSchedulerBiases, type WeightedSchedulerConfig, Worker, type WorkerCatalog, type WorkerConcurrencyOptions, WorkerQueueManager, type WorkerQueueManagerOptions, type WorkerQueueOptions, createDefaultRetryStrategy, defaultRetryOptions, isAbortError, noopTelemetry };
|
|
2129
|
+
export { type AnyMessageCatalog, type AnyQueueItem, BaseScheduler, type BatchConfig, BatchedSpanManager, type BatchedSpanManagerOptions, CallbackFairQueueKeyProducer, type ClaimResult, type ConcurrencyCheckResult, type ConcurrencyGroupConfig, ConcurrencyManager, type ConcurrencyManagerOptions, type ConcurrencyState, type ConsumerLoopState, type CooloffOptions, CronSchema, CustomRetry, DRRScheduler, type DRRSchedulerConfig, type DeadLetterMessage, DefaultFairQueueKeyProducer, type DispatchSchedulerContext, type EnqueueBatchOptions, type EnqueueOptions, ExponentialBackoffRetry, FairQueue, FairQueueAttributes, type FairQueueKeyProducer, type FairQueueMetrics, type FairQueueOptions, FairQueueTelemetry, type FairScheduler, FixedDelayRetry, type GlobalRateLimiter, ImmediateRetry, type InFlightMessage, type JobHandler, type JobHandlerParams, LinearBackoffRetry, MasterQueue, type MasterQueueOptions, type MessageCatalogKey, type MessageCatalogSchema, type MessageCatalogValue, type MessageHandler, type MessageHandlerContext, MessagingAttributes, NoRetry, NoopScheduler, type QueueCooloffState, type QueueDescriptor, type QueueItem, type QueueMessage, type QueueWithScore, type ReclaimedMessageInfo, type RetryOptions, type RetryStrategy, RoundRobinScheduler, type SchedulerContext, SimpleQueue, type StoredMessage, type TelemetryOptions, TenantDispatch, type TenantDispatchOptions, type TenantQueues, type TenantWithScore, VisibilityManager, type VisibilityManagerOptions, WeightedScheduler, type WeightedSchedulerBiases, type WeightedSchedulerConfig, Worker, type WorkerCatalog, type WorkerConcurrencyOptions, WorkerQueueManager, type WorkerQueueManagerOptions, type WorkerQueueOptions, createDefaultRetryStrategy, defaultRetryOptions, isAbortError, noopTelemetry };
|