@trigger.dev/redis-worker 4.4.6 → 4.5.0-rc.0

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.d.cts CHANGED
@@ -2126,4 +2126,154 @@ declare module "@internal/redis" {
2126
2126
  }
2127
2127
  }
2128
2128
 
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 };
2129
+ declare const BufferEntryStatus: z.ZodEnum<["QUEUED", "DRAINING", "FAILED"]>;
2130
+ type BufferEntryStatus = z.infer<typeof BufferEntryStatus>;
2131
+ declare const BufferEntryError: z.ZodObject<{
2132
+ code: z.ZodString;
2133
+ message: z.ZodString;
2134
+ }, "strip", z.ZodTypeAny, {
2135
+ message: string;
2136
+ code: string;
2137
+ }, {
2138
+ message: string;
2139
+ code: string;
2140
+ }>;
2141
+ type BufferEntryError = z.infer<typeof BufferEntryError>;
2142
+ declare const BufferEntrySchema: z.ZodObject<{
2143
+ runId: z.ZodString;
2144
+ envId: z.ZodString;
2145
+ orgId: z.ZodString;
2146
+ payload: z.ZodString;
2147
+ status: z.ZodEnum<["QUEUED", "DRAINING", "FAILED"]>;
2148
+ attempts: z.ZodEffects<z.ZodString, number, string>;
2149
+ createdAt: z.ZodEffects<z.ZodString, Date, string>;
2150
+ lastError: z.ZodOptional<z.ZodEffects<z.ZodString, {
2151
+ message: string;
2152
+ code: string;
2153
+ }, string>>;
2154
+ }, "strip", z.ZodTypeAny, {
2155
+ status: "QUEUED" | "FAILED" | "DRAINING";
2156
+ payload: string;
2157
+ createdAt: Date;
2158
+ runId: string;
2159
+ envId: string;
2160
+ orgId: string;
2161
+ attempts: number;
2162
+ lastError?: {
2163
+ message: string;
2164
+ code: string;
2165
+ } | undefined;
2166
+ }, {
2167
+ status: "QUEUED" | "FAILED" | "DRAINING";
2168
+ payload: string;
2169
+ createdAt: string;
2170
+ runId: string;
2171
+ envId: string;
2172
+ orgId: string;
2173
+ attempts: string;
2174
+ lastError?: string | undefined;
2175
+ }>;
2176
+ type BufferEntry = z.infer<typeof BufferEntrySchema>;
2177
+ declare function serialiseSnapshot(snapshot: unknown): string;
2178
+ declare function deserialiseSnapshot<T = unknown>(serialised: string): T;
2179
+
2180
+ type MollifierBufferOptions = {
2181
+ redisOptions: RedisOptions;
2182
+ entryTtlSeconds: number;
2183
+ logger?: Logger;
2184
+ };
2185
+ declare class MollifierBuffer {
2186
+ #private;
2187
+ private readonly redis;
2188
+ private readonly entryTtlSeconds;
2189
+ private readonly logger;
2190
+ constructor(options: MollifierBufferOptions);
2191
+ accept(input: {
2192
+ runId: string;
2193
+ envId: string;
2194
+ orgId: string;
2195
+ payload: string;
2196
+ }): Promise<boolean>;
2197
+ pop(envId: string): Promise<BufferEntry | null>;
2198
+ getEntry(runId: string): Promise<BufferEntry | null>;
2199
+ listOrgs(): Promise<string[]>;
2200
+ listEnvsForOrg(orgId: string): Promise<string[]>;
2201
+ ack(runId: string): Promise<void>;
2202
+ requeue(runId: string): Promise<void>;
2203
+ fail(runId: string, error: {
2204
+ code: string;
2205
+ message: string;
2206
+ }): Promise<boolean>;
2207
+ getEntryTtlSeconds(runId: string): Promise<number>;
2208
+ evaluateTrip(envId: string, options: {
2209
+ windowMs: number;
2210
+ threshold: number;
2211
+ holdMs: number;
2212
+ }): Promise<{
2213
+ tripped: boolean;
2214
+ count: number;
2215
+ }>;
2216
+ close(): Promise<void>;
2217
+ }
2218
+ declare module "@internal/redis" {
2219
+ interface RedisCommander<Context> {
2220
+ acceptMollifierEntry(entryKey: string, queueKey: string, orgsKey: string, runId: string, envId: string, orgId: string, payload: string, createdAt: string, ttlSeconds: string, orgEnvsPrefix: string, callback?: Callback<number>): Result<number, Context>;
2221
+ popAndMarkDraining(queueKey: string, orgsKey: string, entryPrefix: string, envId: string, orgEnvsPrefix: string, callback?: Callback<string | null>): Result<string | null, Context>;
2222
+ requeueMollifierEntry(entryKey: string, orgsKey: string, queuePrefix: string, runId: string, orgEnvsPrefix: string, callback?: Callback<number>): Result<number, Context>;
2223
+ failMollifierEntry(entryKey: string, errorPayload: string, callback?: Callback<number>): Result<number, Context>;
2224
+ mollifierEvaluateTrip(rateKey: string, trippedKey: string, windowMs: string, threshold: string, holdMs: string, callback?: Callback<[number, number]>): Result<[number, number], Context>;
2225
+ }
2226
+ }
2227
+
2228
+ type MollifierDrainerHandler<TPayload> = (input: {
2229
+ runId: string;
2230
+ envId: string;
2231
+ orgId: string;
2232
+ payload: TPayload;
2233
+ attempts: number;
2234
+ createdAt: Date;
2235
+ }) => Promise<void>;
2236
+ type MollifierDrainerOptions<TPayload> = {
2237
+ buffer: MollifierBuffer;
2238
+ handler: MollifierDrainerHandler<TPayload>;
2239
+ concurrency: number;
2240
+ maxAttempts: number;
2241
+ isRetryable: (err: unknown) => boolean;
2242
+ pollIntervalMs?: number;
2243
+ maxOrgsPerTick?: number;
2244
+ logger?: Logger;
2245
+ };
2246
+ type DrainResult = {
2247
+ drained: number;
2248
+ failed: number;
2249
+ };
2250
+ declare class MollifierDrainer<TPayload = unknown> {
2251
+ private readonly buffer;
2252
+ private readonly handler;
2253
+ private readonly maxAttempts;
2254
+ private readonly isRetryable;
2255
+ private readonly pollIntervalMs;
2256
+ private readonly maxOrgsPerTick;
2257
+ private readonly logger;
2258
+ private readonly limit;
2259
+ private orgCursor;
2260
+ private perOrgEnvCursors;
2261
+ private isRunning;
2262
+ private stopping;
2263
+ private loopPromise;
2264
+ constructor(options: MollifierDrainerOptions<TPayload>);
2265
+ runOnce(): Promise<DrainResult>;
2266
+ start(): void;
2267
+ stop(options?: {
2268
+ timeoutMs?: number;
2269
+ }): Promise<void>;
2270
+ private loop;
2271
+ private backoffMs;
2272
+ private delay;
2273
+ private takeOrgSlice;
2274
+ private pickEnvForOrg;
2275
+ private processOneFromEnv;
2276
+ private processEntry;
2277
+ }
2278
+
2279
+ export { type AnyMessageCatalog, type AnyQueueItem, BaseScheduler, type BatchConfig, BatchedSpanManager, type BatchedSpanManagerOptions, type BufferEntry, BufferEntryError, BufferEntrySchema, BufferEntryStatus, 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 DrainResult, 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, MollifierBuffer, type MollifierBufferOptions, MollifierDrainer, type MollifierDrainerHandler, type MollifierDrainerOptions, 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, deserialiseSnapshot, isAbortError, noopTelemetry, serialiseSnapshot };
package/dist/index.d.ts CHANGED
@@ -2126,4 +2126,154 @@ declare module "@internal/redis" {
2126
2126
  }
2127
2127
  }
2128
2128
 
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 };
2129
+ declare const BufferEntryStatus: z.ZodEnum<["QUEUED", "DRAINING", "FAILED"]>;
2130
+ type BufferEntryStatus = z.infer<typeof BufferEntryStatus>;
2131
+ declare const BufferEntryError: z.ZodObject<{
2132
+ code: z.ZodString;
2133
+ message: z.ZodString;
2134
+ }, "strip", z.ZodTypeAny, {
2135
+ message: string;
2136
+ code: string;
2137
+ }, {
2138
+ message: string;
2139
+ code: string;
2140
+ }>;
2141
+ type BufferEntryError = z.infer<typeof BufferEntryError>;
2142
+ declare const BufferEntrySchema: z.ZodObject<{
2143
+ runId: z.ZodString;
2144
+ envId: z.ZodString;
2145
+ orgId: z.ZodString;
2146
+ payload: z.ZodString;
2147
+ status: z.ZodEnum<["QUEUED", "DRAINING", "FAILED"]>;
2148
+ attempts: z.ZodEffects<z.ZodString, number, string>;
2149
+ createdAt: z.ZodEffects<z.ZodString, Date, string>;
2150
+ lastError: z.ZodOptional<z.ZodEffects<z.ZodString, {
2151
+ message: string;
2152
+ code: string;
2153
+ }, string>>;
2154
+ }, "strip", z.ZodTypeAny, {
2155
+ status: "QUEUED" | "FAILED" | "DRAINING";
2156
+ payload: string;
2157
+ createdAt: Date;
2158
+ runId: string;
2159
+ envId: string;
2160
+ orgId: string;
2161
+ attempts: number;
2162
+ lastError?: {
2163
+ message: string;
2164
+ code: string;
2165
+ } | undefined;
2166
+ }, {
2167
+ status: "QUEUED" | "FAILED" | "DRAINING";
2168
+ payload: string;
2169
+ createdAt: string;
2170
+ runId: string;
2171
+ envId: string;
2172
+ orgId: string;
2173
+ attempts: string;
2174
+ lastError?: string | undefined;
2175
+ }>;
2176
+ type BufferEntry = z.infer<typeof BufferEntrySchema>;
2177
+ declare function serialiseSnapshot(snapshot: unknown): string;
2178
+ declare function deserialiseSnapshot<T = unknown>(serialised: string): T;
2179
+
2180
+ type MollifierBufferOptions = {
2181
+ redisOptions: RedisOptions;
2182
+ entryTtlSeconds: number;
2183
+ logger?: Logger;
2184
+ };
2185
+ declare class MollifierBuffer {
2186
+ #private;
2187
+ private readonly redis;
2188
+ private readonly entryTtlSeconds;
2189
+ private readonly logger;
2190
+ constructor(options: MollifierBufferOptions);
2191
+ accept(input: {
2192
+ runId: string;
2193
+ envId: string;
2194
+ orgId: string;
2195
+ payload: string;
2196
+ }): Promise<boolean>;
2197
+ pop(envId: string): Promise<BufferEntry | null>;
2198
+ getEntry(runId: string): Promise<BufferEntry | null>;
2199
+ listOrgs(): Promise<string[]>;
2200
+ listEnvsForOrg(orgId: string): Promise<string[]>;
2201
+ ack(runId: string): Promise<void>;
2202
+ requeue(runId: string): Promise<void>;
2203
+ fail(runId: string, error: {
2204
+ code: string;
2205
+ message: string;
2206
+ }): Promise<boolean>;
2207
+ getEntryTtlSeconds(runId: string): Promise<number>;
2208
+ evaluateTrip(envId: string, options: {
2209
+ windowMs: number;
2210
+ threshold: number;
2211
+ holdMs: number;
2212
+ }): Promise<{
2213
+ tripped: boolean;
2214
+ count: number;
2215
+ }>;
2216
+ close(): Promise<void>;
2217
+ }
2218
+ declare module "@internal/redis" {
2219
+ interface RedisCommander<Context> {
2220
+ acceptMollifierEntry(entryKey: string, queueKey: string, orgsKey: string, runId: string, envId: string, orgId: string, payload: string, createdAt: string, ttlSeconds: string, orgEnvsPrefix: string, callback?: Callback<number>): Result<number, Context>;
2221
+ popAndMarkDraining(queueKey: string, orgsKey: string, entryPrefix: string, envId: string, orgEnvsPrefix: string, callback?: Callback<string | null>): Result<string | null, Context>;
2222
+ requeueMollifierEntry(entryKey: string, orgsKey: string, queuePrefix: string, runId: string, orgEnvsPrefix: string, callback?: Callback<number>): Result<number, Context>;
2223
+ failMollifierEntry(entryKey: string, errorPayload: string, callback?: Callback<number>): Result<number, Context>;
2224
+ mollifierEvaluateTrip(rateKey: string, trippedKey: string, windowMs: string, threshold: string, holdMs: string, callback?: Callback<[number, number]>): Result<[number, number], Context>;
2225
+ }
2226
+ }
2227
+
2228
+ type MollifierDrainerHandler<TPayload> = (input: {
2229
+ runId: string;
2230
+ envId: string;
2231
+ orgId: string;
2232
+ payload: TPayload;
2233
+ attempts: number;
2234
+ createdAt: Date;
2235
+ }) => Promise<void>;
2236
+ type MollifierDrainerOptions<TPayload> = {
2237
+ buffer: MollifierBuffer;
2238
+ handler: MollifierDrainerHandler<TPayload>;
2239
+ concurrency: number;
2240
+ maxAttempts: number;
2241
+ isRetryable: (err: unknown) => boolean;
2242
+ pollIntervalMs?: number;
2243
+ maxOrgsPerTick?: number;
2244
+ logger?: Logger;
2245
+ };
2246
+ type DrainResult = {
2247
+ drained: number;
2248
+ failed: number;
2249
+ };
2250
+ declare class MollifierDrainer<TPayload = unknown> {
2251
+ private readonly buffer;
2252
+ private readonly handler;
2253
+ private readonly maxAttempts;
2254
+ private readonly isRetryable;
2255
+ private readonly pollIntervalMs;
2256
+ private readonly maxOrgsPerTick;
2257
+ private readonly logger;
2258
+ private readonly limit;
2259
+ private orgCursor;
2260
+ private perOrgEnvCursors;
2261
+ private isRunning;
2262
+ private stopping;
2263
+ private loopPromise;
2264
+ constructor(options: MollifierDrainerOptions<TPayload>);
2265
+ runOnce(): Promise<DrainResult>;
2266
+ start(): void;
2267
+ stop(options?: {
2268
+ timeoutMs?: number;
2269
+ }): Promise<void>;
2270
+ private loop;
2271
+ private backoffMs;
2272
+ private delay;
2273
+ private takeOrgSlice;
2274
+ private pickEnvForOrg;
2275
+ private processOneFromEnv;
2276
+ private processEntry;
2277
+ }
2278
+
2279
+ export { type AnyMessageCatalog, type AnyQueueItem, BaseScheduler, type BatchConfig, BatchedSpanManager, type BatchedSpanManagerOptions, type BufferEntry, BufferEntryError, BufferEntrySchema, BufferEntryStatus, 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 DrainResult, 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, MollifierBuffer, type MollifierBufferOptions, MollifierDrainer, type MollifierDrainerHandler, type MollifierDrainerOptions, 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, deserialiseSnapshot, isAbortError, noopTelemetry, serialiseSnapshot };