Projektstart

This commit is contained in:
2026-01-22 15:49:12 +01:00
parent 7212eb6f7a
commit 57e5f652f8
10637 changed files with 2598792 additions and 64 deletions

View File

@@ -0,0 +1,19 @@
import { BackoffStrategy } from '../types/backoff-strategy';
import { RepeatStrategy } from '../types/repeat-strategy';
export interface AdvancedRepeatOptions {
/**
* A custom cron strategy.
*/
repeatStrategy?: RepeatStrategy;
/**
* A hash algorithm to be used when trying to create the job redis key.
* Default - md5
*/
repeatKeyHashAlgorithm?: string;
}
export interface AdvancedOptions extends AdvancedRepeatOptions {
/**
* A custom backoff strategy.
*/
backoffStrategy?: BackoffStrategy;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=advanced-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"advanced-options.js","sourceRoot":"","sources":["../../../src/interfaces/advanced-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,20 @@
/**
* Settings for backing off failed jobs.
*
* @see {@link https://docs.bullmq.io/guide/retrying-failing-jobs}
*/
export interface BackoffOptions {
/**
* Name of the backoff strategy.
*/
type: 'fixed' | 'exponential' | (string & {});
/**
* Delay in milliseconds.
*/
delay?: number;
/**
* Percentage of jitter usage.
* @defaultValue 0
*/
jitter?: number;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=backoff-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"backoff-options.js","sourceRoot":"","sources":["../../../src/interfaces/backoff-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,94 @@
import { BackoffOptions } from './backoff-options';
import { KeepJobs } from '../types/keep-jobs';
import { ParentOptions } from './parent-options';
import { RepeatOptions } from './repeat-options';
export interface DefaultJobOptions {
/**
* Timestamp when the job was created.
* @defaultValue Date.now()
*/
timestamp?: number;
/**
* Ranges from 0 (highest priority) to 2 097 152 (lowest priority). Note that
* using priorities has a slight impact on performance,
* so do not use it if not required.
* @defaultValue 0
*/
priority?: number;
/**
* An amount of milliseconds to wait until this job can be processed.
* Note that for accurate delays, worker and producers
* should have their clocks synchronized.
* @defaultValue 0
*/
delay?: number;
/**
* The total number of attempts to try the job until it completes.
* @defaultValue 1
*/
attempts?: number;
/**
* Backoff setting for automatic retries if the job fails
*/
backoff?: number | BackoffOptions;
/**
* If true, adds the job to the right of the queue instead of the left (default false)
*
* @see {@link https://docs.bullmq.io/guide/jobs/lifo}
*/
lifo?: boolean;
/**
* If true, removes the job when it successfully completes
* When given a number, it specifies the maximum amount of
* jobs to keep, or you can provide an object specifying max
* age and/or count to keep. It overrides whatever setting is used in the worker.
* Default behavior is to keep the job in the completed set.
*/
removeOnComplete?: boolean | number | KeepJobs;
/**
* If true, removes the job when it fails after all attempts.
* When given a number, it specifies the maximum amount of
* jobs to keep, or you can provide an object specifying max
* age and/or count to keep. It overrides whatever setting is used in the worker.
* Default behavior is to keep the job in the failed set.
*/
removeOnFail?: boolean | number | KeepJobs;
/**
* Maximum amount of log entries that will be preserved
*/
keepLogs?: number;
/**
* Limits the amount of stack trace lines that will be recorded in the stacktrace.
*/
stackTraceLimit?: number;
/**
* Limits the size in bytes of the job's data payload (as a JSON serialized string).
*/
sizeLimit?: number;
}
export interface BaseJobOptions extends DefaultJobOptions {
/**
* Repeat this job, for example based on a `cron` schedule.
*/
repeat?: RepeatOptions;
/**
* Internal property used by repeatable jobs to save base repeat job key.
*/
repeatJobKey?: string;
/**
* Override the job ID - by default, the job ID is a unique
* integer, but you can use this setting to override it.
* If you use this option, it is up to you to ensure the
* jobId is unique. If you attempt to add a job with an id that
* already exists, it will not be added.
*/
jobId?: string;
/**
* Parent options
*/
parent?: ParentOptions;
/**
* Internal property used by repeatable jobs.
*/
prevMillis?: number;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=base-job-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base-job-options.js","sourceRoot":"","sources":["../../../src/interfaces/base-job-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
import { ParentCommand } from '../enums/parent-command';
export interface ChildMessage {
cmd: ParentCommand;
requestId?: string;
value?: any;
err?: Record<string, any>;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=child-message.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"child-message.js","sourceRoot":"","sources":["../../../src/interfaces/child-message.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
import { EventEmitter } from 'events';
import { Cluster, Redis } from 'ioredis';
export type RedisClient = Redis | Cluster;
export interface IConnection extends EventEmitter {
waitUntilReady(): Promise<boolean>;
client: Promise<RedisClient>;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=connection.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/interfaces/connection.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,19 @@
import { JobsOptions } from '../types';
import { QueueOptions } from './queue-options';
export interface FlowJobBase<T> {
name: string;
queueName: string;
data?: any;
prefix?: string;
opts?: Omit<T, 'debounce' | 'deduplication' | 'repeat'>;
children?: FlowChildJob[];
}
export type FlowChildJob = FlowJobBase<Omit<JobsOptions, 'debounce' | 'deduplication' | 'parent' | 'repeat'>>;
export type FlowJob = FlowJobBase<JobsOptions>;
export type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
export interface FlowOpts {
/**
* Map of options for Queue classes.
*/
queuesOptions: FlowQueuesOpts;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=flow-job.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"flow-job.js","sourceRoot":"","sources":["../../../src/interfaces/flow-job.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,33 @@
export * from './advanced-options';
export * from './backoff-options';
export * from './base-job-options';
export * from './child-message';
export * from './connection';
export * from './flow-job';
export * from './ioredis-events';
export * from './job-json';
export * from './job-scheduler-json';
export * from './lock-manager-worker-context';
export * from './metrics-options';
export * from './metrics';
export * from './minimal-job';
export * from './minimal-queue';
export * from './parent-message';
export * from './parent';
export * from './parent-options';
export * from './queue-meta';
export * from './queue-options';
export * from './rate-limiter-options';
export * from './redis-options';
export * from './redis-streams';
export * from './repeatable-job';
export * from './repeatable-options';
export * from './repeat-options';
export * from './retry-options';
export * from './script-queue-context';
export * from './sandboxed-job-processor';
export * from './sandboxed-job';
export * from './sandboxed-options';
export * from './worker-options';
export * from './telemetry';
export * from './receiver';

View File

@@ -0,0 +1,34 @@
export * from './advanced-options';
export * from './backoff-options';
export * from './base-job-options';
export * from './child-message';
export * from './connection';
export * from './flow-job';
export * from './ioredis-events';
export * from './job-json';
export * from './job-scheduler-json';
export * from './lock-manager-worker-context';
export * from './metrics-options';
export * from './metrics';
export * from './minimal-job';
export * from './minimal-queue';
export * from './parent-message';
export * from './parent';
export * from './parent-options';
export * from './queue-meta';
export * from './queue-options';
export * from './rate-limiter-options';
export * from './redis-options';
export * from './redis-streams';
export * from './repeatable-job';
export * from './repeatable-options';
export * from './repeat-options';
export * from './retry-options';
export * from './script-queue-context';
export * from './sandboxed-job-processor';
export * from './sandboxed-job';
export * from './sandboxed-options';
export * from './worker-options';
export * from './telemetry';
export * from './receiver';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}

View File

@@ -0,0 +1,8 @@
export interface IoredisListener {
/**
* Listen to 'ioredis:close' event.
*
* This event is triggered when ioredis is closed.
*/
'ioredis:close': () => void;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ioredis-events.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ioredis-events.js","sourceRoot":"","sources":["../../../src/interfaces/ioredis-events.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,52 @@
import { JobProgress } from '../types/job-progress';
import { RedisJobOptions } from '../types/job-options';
import { ParentKeys } from './parent';
export interface JobJson {
id: string;
name: string;
data: string;
opts: RedisJobOptions;
progress: JobProgress;
attemptsMade: number;
attemptsStarted: number;
finishedOn?: number;
processedOn?: number;
timestamp: number;
failedReason: string;
stacktrace: string;
returnvalue: string;
parent?: ParentKeys;
parentKey?: string;
repeatJobKey?: string;
nextRepeatableJobKey?: string;
debounceId?: string;
deduplicationId?: string;
processedBy?: string;
stalledCounter: number;
}
export interface JobJsonRaw {
id: string;
name: string;
data: string;
delay: string;
opts: string;
progress: string;
attemptsMade?: string;
finishedOn?: string;
processedOn?: string;
priority: string;
timestamp: string;
failedReason: string;
stacktrace?: string;
returnvalue: string;
parentKey?: string;
parent?: string;
deid?: string;
rjk?: string;
nrjid?: string;
atm?: string;
defa?: string;
stc?: string;
ats?: string;
pb?: string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=job-json.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"job-json.js","sourceRoot":"","sources":["../../../src/interfaces/job-json.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,20 @@
import { JobSchedulerTemplateOptions } from '../types';
export interface JobSchedulerTemplateJson<D = any> {
data?: D;
opts?: JobSchedulerTemplateOptions;
}
export interface JobSchedulerJson<D = any> {
key: string;
name: string;
id?: string | null;
iterationCount?: number;
limit?: number;
startDate?: number;
endDate?: number;
tz?: string;
pattern?: string;
every?: number;
next?: number;
offset?: number;
template?: JobSchedulerTemplateJson<D>;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=job-scheduler-json.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"job-scheduler-json.js","sourceRoot":"","sources":["../../../src/interfaces/job-scheduler-json.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,23 @@
import { Span } from './telemetry';
/**
* Minimal interface that LockManager needs from Worker.
* This allows LockManager to access worker methods without inheriting from QueueBase.
*/
export interface LockManagerWorkerContext {
/**
* Extends locks for multiple jobs.
*/
extendJobLocks(jobIds: string[], tokens: string[], duration: number): Promise<string[]>;
/**
* Emits events to worker listeners.
*/
emit(event: string | symbol, ...args: any[]): boolean;
/**
* Wraps code with telemetry tracing.
*/
trace<T>(spanKind: any, operation: string, destination: string, callback: (span?: Span) => Promise<T> | T): Promise<T> | T;
/**
* Queue name for telemetry.
*/
name: string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=lock-manager-worker-context.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"lock-manager-worker-context.js","sourceRoot":"","sources":["../../../src/interfaces/lock-manager-worker-context.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,12 @@
/**
*
*
*/
export interface MetricsOptions {
/**
* Enable gathering metrics for finished jobs.
* Output refers to all finished jobs, completed or
* failed.
*/
maxDataPoints?: number;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=metrics-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"metrics-options.js","sourceRoot":"","sources":["../../../src/interfaces/metrics-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,9 @@
export interface Metrics {
meta: {
count: number;
prevTS: number;
prevCount: number;
};
data: number[];
count: number;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=metrics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/interfaces/metrics.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,154 @@
import { JobsOptions } from '../types/job-options';
import { JobProgress } from '../types/job-progress';
import { JobJsonSandbox } from '../types/job-json-sandbox';
import { JobJson } from './job-json';
import { ParentKeys } from './parent';
import { ParentOptions } from './parent-options';
export type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
export interface MoveToDelayedOpts {
skipAttempt?: boolean;
fieldsToUpdate?: Record<string, any>;
}
export interface RetryJobOpts {
fieldsToUpdate?: Record<string, any>;
}
export interface MoveToWaitingChildrenOpts {
child?: ParentOptions;
}
export interface DependencyOpts {
/**
* Cursor value to be passed for pagination
*/
cursor?: number;
/**
* Max quantity of jobs to be retrieved
*/
count?: number;
}
export interface DependenciesOpts {
/**
* Options for failed child pagination
*/
failed?: DependencyOpts;
/**
* Options for ignored child pagination
*/
ignored?: DependencyOpts;
/**
* Options for processed child pagination
*/
processed?: DependencyOpts;
/**
* Options for unprocessed child pagination
*/
unprocessed?: DependencyOpts;
}
/**
* MinimalJob
*/
export interface MinimalJob<DataType = any, ReturnType = any, NameType extends string = string> {
/**
* The name of the Job
*/
name: NameType;
/**
* The payload for this job.
*/
data: DataType;
/**
* The options object for this job.
*/
opts: JobsOptions;
id?: string;
/**
* The progress a job has performed so far.
* @defaultValue 0
*/
progress: JobProgress;
/**
* The value returned by the processor when processing this job.
* @defaultValue null
*/
returnvalue: ReturnType;
/**
* Stacktrace for the error (for failed jobs).
* @defaultValue null
*/
stacktrace: string[];
/**
* An amount of milliseconds to wait until this job can be processed.
* @defaultValue 0
*/
delay: number;
/**
* Timestamp when the job was created (unless overridden with job options).
*/
timestamp: number;
/**
* Number of attempts after the job has failed.
* @defaultValue 0
*/
attemptsMade: number;
/**
* Reason for failing.
*/
failedReason: string;
/**
* Timestamp for when the job finished (completed or failed).
*/
finishedOn?: number;
/**
* Timestamp for when the job was processed.
*/
processedOn?: number;
/**
* Fully qualified key (including the queue prefix) pointing to the parent of this job.
*/
parentKey?: string;
/**
* Object that contains parentId (id) and parent queueKey.
*/
parent?: ParentKeys;
/**
* Base repeat job key.
*/
repeatJobKey?: string;
/**
* Prepares a job to be serialized for storage in Redis.
* @returns
*/
asJSON(): JobJson;
/**
* Prepares a job to be passed to Sandbox.
* @returns
*/
asJSONSandbox(): JobJsonSandbox;
/**
* Updates a job's data
*
* @param data - the data that will replace the current jobs data.
*/
updateData(data: DataType): Promise<void>;
/**
* Updates a job's progress
*
* @param progress - number or object to be saved as progress.
*/
updateProgress(progress: JobProgress): Promise<void>;
/**
* Logs one row of log data.
*
* @param logRow - string with log data to be logged.
*/
log(logRow: string): Promise<number>;
get queueName(): string;
/**
* @returns the prefix that is used.
*/
get prefix(): string;
/**
* @returns it includes the prefix, the namespace separator :, and queue name.
* @see https://www.gnu.org/software/gawk/manual/html_node/Qualified-Names.html
*/
get queueQualifiedName(): string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=minimal-job.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"minimal-job.js","sourceRoot":"","sources":["../../../src/interfaces/minimal-job.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,30 @@
import { RedisClient } from './connection';
import { Span } from './telemetry';
import { SpanKind } from '../enums/telemetry-attributes';
import { ScriptQueueContext } from './script-queue-context';
export interface MinimalQueue extends ScriptQueueContext {
readonly name: string;
readonly qualifiedName: string;
/**
* Emits an event. Normally used by subclasses to emit events.
*
* @param event - The emitted event.
* @param args -
* @returns
*/
emit(event: string | symbol, ...args: any[]): boolean;
on(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
waitUntilReady(): Promise<RedisClient>;
/**
* Wraps the code with telemetry and provides a span for configuration.
*
* @param spanKind - kind of the span: Producer, Consumer, Internal
* @param operation - operation name (such as add, process, etc)
* @param destination - destination name (normally the queue name)
* @param callback - code to wrap with telemetry
* @param srcPropagationMedatada -
* @returns
*/
trace<T>(spanKind: SpanKind, operation: string, destination: string, callback: (span?: Span, dstPropagationMetadata?: string) => Promise<T> | T, srcPropagationMetadata?: string): Promise<T | Promise<T>>;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=minimal-queue.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"minimal-queue.js","sourceRoot":"","sources":["../../../src/interfaces/minimal-queue.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import { ChildCommand } from '../enums/child-command';
import { JobJson } from './job-json';
export interface ParentMessage {
cmd: ChildCommand;
value?: any;
err?: Error;
job?: JobJson;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=parent-message.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parent-message.js","sourceRoot":"","sources":["../../../src/interfaces/parent-message.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,11 @@
export interface ParentOptions {
/**
* Parent identifier.
*/
id: string;
/**
* It includes the prefix, the namespace separator :, and queue name.
* @see {@link https://www.gnu.org/software/gawk/manual/html_node/Qualified-Names.html}
*/
queue: string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=parent-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parent-options.js","sourceRoot":"","sources":["../../../src/interfaces/parent-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,24 @@
import { JobsOptions } from '../types/job-options';
/**
* Describes the parent for a Job.
*/
export interface Parent<T> {
name: string;
prefix?: string;
queue?: string;
data?: T;
opts?: JobsOptions;
}
export interface ParentKeys {
id?: string;
queueKey: string;
fpof?: boolean;
rdof?: boolean;
idof?: boolean;
cpof?: boolean;
}
export type ParentKeyOpts = {
addToWaitingChildren?: boolean;
parentDependenciesKey?: string;
parentKey?: string;
};

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=parent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parent.js","sourceRoot":"","sources":["../../../src/interfaces/parent.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
export interface QueueMeta {
concurrency?: number;
max?: number;
duration?: number;
maxLenEvents?: number;
paused?: boolean;
version?: string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=queue-meta.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"queue-meta.js","sourceRoot":"","sources":["../../../src/interfaces/queue-meta.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,106 @@
import { AdvancedRepeatOptions } from './advanced-options';
import { DefaultJobOptions } from './base-job-options';
import { ConnectionOptions } from './redis-options';
import { Telemetry } from './telemetry';
export declare enum ClientType {
blocking = "blocking",
normal = "normal"
}
/**
* Base Queue options
*/
export interface QueueBaseOptions {
/**
* Options for connecting to a Redis instance.
*/
connection: ConnectionOptions;
/**
* Denotes commands should retry indefinitely.
* @deprecated not in use anymore.
*/
blockingConnection?: boolean;
/**
* Prefix for all queue keys.
*/
prefix?: string;
/**
* Avoid version validation to be greater or equal than v5.0.0.
* @defaultValue false
*/
skipVersionCheck?: boolean;
/**
* Telemetry client
*/
telemetry?: Telemetry;
/**
* Skip waiting for connection ready.
*
* In some instances if you want the queue to fail fast if the connection is
* not ready you can set this to true. This could be useful for testing and when
* adding jobs via HTTP endpoints for example.
*
*/
skipWaitingForReady?: boolean;
}
/**
* Options for the Queue class.
*/
export interface QueueOptions extends QueueBaseOptions {
defaultJobOptions?: DefaultJobOptions;
/**
* Options for the streams used internally in BullMQ.
*/
streams?: {
/**
* Options for the events stream.
*/
events: {
/**
* Max approximated length for streams. Default is 10 000 events.
*/
maxLen: number;
};
};
/**
* Skip Meta update.
*
* If true, the queue will not update the metadata of the queue.
* Useful for read-only systems that do should not update the metadata.
*
* @defaultValue false
*/
skipMetasUpdate?: boolean;
/**
* Advanced options for the repeatable jobs.
*/
settings?: AdvancedRepeatOptions;
}
/**
* Options for the Repeat class.
*/
export interface RepeatBaseOptions extends QueueBaseOptions {
settings?: AdvancedRepeatOptions;
}
/**
* Options for QueueEvents
*/
export interface QueueEventsOptions extends Omit<QueueBaseOptions, 'telemetry'> {
/**
* Condition to start listening to events at instance creation.
*/
autorun?: boolean;
/**
* Last event Id. If provided it is possible to continue
* consuming events from a known Id instead of from the last
* produced event.
*/
lastEventId?: string;
/**
* Timeout for the blocking XREAD call to the events stream.
*/
blockingTimeout?: number;
}
/**
* Options for QueueEventsProducer
*/
export type QueueEventsProducerOptions = Omit<QueueBaseOptions, 'telemetry'>;

View File

@@ -0,0 +1,6 @@
export var ClientType;
(function (ClientType) {
ClientType["blocking"] = "blocking";
ClientType["normal"] = "normal";
})(ClientType || (ClientType = {}));
//# sourceMappingURL=queue-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"queue-options.js","sourceRoot":"","sources":["../../../src/interfaces/queue-options.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}

View File

@@ -0,0 +1,12 @@
export interface RateLimiterOptions {
/**
* Max number of jobs to process in the time period
* specified in `duration`.
*/
max: number;
/**
* Time in milliseconds. During this time, a maximum
* of `max` jobs will be processed.
*/
duration: number;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=rate-limiter-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rate-limiter-options.js","sourceRoot":"","sources":["../../../src/interfaces/rate-limiter-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,4 @@
export interface Receiver {
on: (evt: 'message', cb: (msg: any) => void) => void;
off: (evt: 'message', cb: (msg: any) => void) => void;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=receiver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../../src/interfaces/receiver.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import type * as IORedis from 'ioredis';
export interface BaseOptions {
skipVersionCheck?: boolean;
url?: string;
}
export type RedisOptions = IORedis.RedisOptions & BaseOptions;
export type ClusterOptions = IORedis.ClusterOptions & BaseOptions;
export type ConnectionOptions = RedisOptions | ClusterOptions | IORedis.Redis | IORedis.Cluster;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=redis-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"redis-options.js","sourceRoot":"","sources":["../../../src/interfaces/redis-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,4 @@
export type StreamName = string;
export type EntryId = string;
export type EntryRaw = [EntryId, string[]];
export type StreamReadRaw = [StreamName, EntryRaw[]][] | null | undefined;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=redis-streams.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"redis-streams.js","sourceRoot":"","sources":["../../../src/interfaces/redis-streams.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,50 @@
import { ParserOptions } from 'cron-parser';
/**
* Settings for repeatable jobs
*
* @see {@link https://docs.bullmq.io/guide/jobs/repeatable}
*/
export interface RepeatOptions extends Omit<ParserOptions, 'iterator'> {
/**
* A repeat pattern
*/
pattern?: string;
/**
* Custom repeatable key. This is the key that holds the "metadata"
* of a given repeatable job. This key is normally auto-generated but
* it is sometimes useful to specify a custom key for easier retrieval
* of repeatable jobs.
*/
key?: string;
/**
* Number of times the job should repeat at max.
*/
limit?: number;
/**
* Repeat after this amount of milliseconds
* (`pattern` setting cannot be used together with this setting.)
*/
every?: number;
/**
* Repeated job should start right now
* ( work only with cron settings)
*/
immediately?: boolean;
/**
* The start value for the repeat iteration count.
*/
count?: number;
/**
* Offset in milliseconds to affect the next iteration time
* */
offset?: number;
/**
* Internal property to store the previous time the job was executed.
*/
prevMillis?: number;
/**
* Internal property to store de job id
* @deprecated not in use anymore
*/
jobId?: string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=repeat-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"repeat-options.js","sourceRoot":"","sources":["../../../src/interfaces/repeat-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,10 @@
export type RepeatableJob = {
key: string;
name: string;
id?: string | null;
endDate: number | null;
tz: string | null;
pattern: string | null;
every?: string | null;
next?: number;
};

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=repeatable-job.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"repeatable-job.js","sourceRoot":"","sources":["../../../src/interfaces/repeatable-job.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,10 @@
export type RepeatableOptions = {
name: string;
startDate?: number;
endDate?: number;
tz?: string;
limit?: number;
pattern?: string;
every?: number;
offset?: number;
};

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=repeatable-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"repeatable-options.js","sourceRoot":"","sources":["../../../src/interfaces/repeatable-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
/**
* Retry method options
*/
export interface RetryOptions {
/**
* Attempts made counter is reset to zero when retrying the job.
*/
resetAttemptsMade?: boolean;
/**
* Attempts started counter is reset to zero when retrying the job.
*/
resetAttemptsStarted?: boolean;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=retry-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"retry-options.js","sourceRoot":"","sources":["../../../src/interfaces/retry-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,5 @@
import { SandboxedJob } from './sandboxed-job';
/**
* @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
*/
export type SandboxedJobProcessor<T = any, R = any> = ((job: SandboxedJob<T, R>) => R | PromiseLike<R>) | ((job: SandboxedJob<T, R>, callback: (error: unknown, result: R) => void) => void);

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sandboxed-job-processor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sandboxed-job-processor.js","sourceRoot":"","sources":["../../../src/interfaces/sandboxed-job-processor.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,17 @@
import { JobJsonSandbox, JobProgress, JobsOptions } from '../types';
import { MoveToWaitingChildrenOpts } from './minimal-job';
/**
* @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
*/
export interface SandboxedJob<T = any, R = any> extends Omit<JobJsonSandbox, 'data' | 'opts' | 'returnValue'> {
data: T;
opts: JobsOptions;
queueQualifiedName: string;
moveToDelayed: (timestamp: number, token?: string) => Promise<void>;
moveToWait: (token?: string) => Promise<void>;
moveToWaitingChildren: (token?: string, opts?: MoveToWaitingChildrenOpts) => Promise<boolean>;
log: (row: any) => void;
updateData: (data: any) => Promise<void>;
updateProgress: (value: JobProgress) => Promise<void>;
returnValue: R;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sandboxed-job.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sandboxed-job.js","sourceRoot":"","sources":["../../../src/interfaces/sandboxed-job.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,26 @@
import { ForkOptions } from 'child_process';
import { WorkerOptions as WorkerThreadsOptions } from 'worker_threads';
export interface SandboxedOptions {
/**
* Use Worker Threads instead of Child Processes.
* Note: This option can only be used when specifying
* a file for the processor argument.
*
* @defaultValue false
*/
useWorkerThreads?: boolean;
/**
* Support passing Worker Fork Options.
* Note: This option can only be used when specifying
* a file for the processor argument and useWorkerThreads is passed as false (default value).
* @see {@link https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options}
*/
workerForkOptions?: ForkOptions;
/**
* Support passing Worker Threads Options.
* Note: This option can only be used when specifying
* a file for the processor argument and useWorkerThreads is passed as true.
* @see {@link https://nodejs.org/api/worker_threads.html#new-workerfilename-options}
*/
workerThreadsOptions?: WorkerThreadsOptions;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sandboxed-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sandboxed-options.js","sourceRoot":"","sources":["../../../src/interfaces/sandboxed-options.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,17 @@
import { RedisClient } from './connection';
import { QueueBaseOptions } from './queue-options';
import { KeysMap } from '../classes/queue-keys';
export interface ScriptQueueContext {
opts: QueueBaseOptions;
toKey: (type: string) => string;
keys: KeysMap;
closing: Promise<void> | undefined;
/**
* Returns a promise that resolves to a redis client. Normally used only by subclasses.
*/
get client(): Promise<RedisClient>;
/**
* Returns the version of the Redis instance the client is connected to,
*/
get redisVersion(): string;
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=script-queue-context.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"script-queue-context.js","sourceRoot":"","sources":["../../../src/interfaces/script-queue-context.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,153 @@
import { SpanKind } from '../enums';
/**
* Telemetry interface
*
* This interface allows third-party libraries to integrate their own telemetry
* system. The interface is heavily inspired by OpenTelemetry but it's not
* limited to it.
*
*/
export interface Telemetry<Context = any> {
/**
* Tracer instance
*
* The tracer is responsible for creating spans and propagating the context
* across the application.
*/
tracer: Tracer<Context>;
/**
* Context manager instance
*
* The context manager is responsible for managing the context and propagating
* it across the application.
*/
contextManager: ContextManager;
}
/**
* Context manager interface
*
* The context manager is responsible for managing the context and propagating
* it across the application.
*/
export interface ContextManager<Context = any> {
/**
* Creates a new context and sets it as active for the fn passed as last argument
*
* @param context - the context to set as active
* @param fn - the function to execute with the context
*/
with<A extends (...args: any[]) => any>(context: Context, fn: A): ReturnType<A>;
/**
* Returns the active context
*/
active(): Context;
/**
* Returns a serialized version of the current context. The metadata
* is the mechanism used to propagate the context across a distributed
* application.
*
* @param context - the current context
*/
getMetadata(context: Context): string;
/**
* Creates a new context from a serialized version effectively
* linking the new context to the parent context.
*
* @param activeContext - the current active context
* @param metadata - the serialized version of the context
*/
fromMetadata(activeContext: Context, metadata: string): Context;
}
/**
* Tracer interface
*
*/
export interface Tracer<Context = any> {
/**
* startSpan creates a new Span with the given name and options on an optional
* context. If the context is not provided, the current active context should be
* used.
*
* @param name - span name
* @param options - span options
* @param context - optional context
* @returns - the created span
*/
startSpan(name: string, options?: SpanOptions, context?: Context): Span;
}
export interface SpanOptions {
kind: SpanKind;
}
/**
* Span interface
*/
export interface Span<Context = any> {
/**
* setSpanOnContext sets the span on the context. This is useful when you want
* to propagate the span across the application.
*
* @param ctx - context to set the span on
* @returns - the context with the span set on it
*/
setSpanOnContext(ctx: Context): Context;
/**
* setAttribute sets an attribute on the span.
*
* @param key - attribute key
* @param value - attribute value
*/
setAttribute(key: string, value: AttributeValue): void;
/**
* setAttributes sets multiple attributes on the span.
*
* @param attributes - attributes to set
*/
setAttributes(attributes: Attributes): void;
/**
* addEvent adds an event to the span.
*
* @param name - event name
* @param attributes - event attributes
*/
addEvent(name: string, attributes?: Attributes): void;
/**
* recordException records an exception on the span.
*
* @param exception - exception to record
* @param time - time to record the exception
*/
recordException(exception: Exception, time?: Time): void;
/**
* end ends the span.
*
* Note: spans must be ended so that they can be exported.
*/
end(): void;
}
export interface Attributes {
[attribute: string]: AttributeValue | undefined;
}
export type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
export type Exception = string | ExceptionType;
export type ExceptionType = CodeException | MessageException | NameException;
interface CodeException {
code: string | number;
name?: string;
message?: string;
stack?: string;
}
interface MessageException {
code?: string | number;
name?: string;
message: string;
stack?: string;
}
interface NameException {
code?: string | number;
name: string;
message?: string;
stack?: string;
}
export type Time = HighResolutionTime | number | Date;
type HighResolutionTime = [number, number];
export {};

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=telemetry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/interfaces/telemetry.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,143 @@
import { AdvancedOptions } from './advanced-options';
import { QueueBaseOptions } from './queue-options';
import { RateLimiterOptions } from './rate-limiter-options';
import { MetricsOptions } from './metrics-options';
import { KeepJobs } from '../types/keep-jobs';
import { Telemetry } from './telemetry';
import { SandboxedOptions } from './sandboxed-options';
export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
/**
* Optional worker name. The name will be stored on every job
* processed by this worker instance, and can be used to monitor
* which worker is processing or has processed a given job.
*/
name?: string;
/**
* Condition to start processor at instance creation.
*
* @defaultValue true
*/
autorun?: boolean;
/**
* Amount of jobs that a single worker is allowed to work on
* in parallel.
*
* @defaultValue 1
* @see {@link https://docs.bullmq.io/guide/workers/concurrency}
*/
concurrency?: number;
/**
* Enable rate limiter
* @see {@link https://docs.bullmq.io/guide/rate-limiting}
*/
limiter?: RateLimiterOptions;
/**
* Enable collect metrics.
* @see {@link https://docs.bullmq.io/guide/metrics}
*/
metrics?: MetricsOptions;
/**
* Maximum time in milliseconds where the job is idle while being rate limited.
* While workers are idle because of a rate limiter, they won't fetch new jobs to process
* and delayed jobs won't be promoted.
* @defaultValue 30000
*/
maximumRateLimitDelay?: number;
/**
* Defines the maximum number of times a job is allowed to start processing,
* regardless of whether it completes or fails. Each time a worker picks up the job
* and begins processing it, the attemptsStarted counter is incremented.
* If this counter reaches maxStartedAttempts, the job will be moved to the failed state with an UnrecoverableError.
* @defaultValue undefined
*/
maxStartedAttempts?: number;
/**
* Amount of times a job can be recovered from a stalled state
* to the `wait` state. If this is exceeded, the job is moved
* to `failed`.
*
* @defaultValue 1
*/
maxStalledCount?: number;
/**
* Number of milliseconds between stallness checks.
*
* @defaultValue 30000
*/
stalledInterval?: number;
/**
* You can provide an object specifying max
* age and/or count to keep.
* Default behavior is to keep the job in the completed set.
*/
removeOnComplete?: KeepJobs;
/**
* You can provide an object specifying max
* age and/or count to keep.
* Default behavior is to keep the job in the failed set.
*/
removeOnFail?: KeepJobs;
/**
* Skip stalled check for this worker. Note that other workers could still
* perform stalled checkd and move jobs back to wait for jobs being processed
* by this worker.
*
* @defaultValue false
*/
skipStalledCheck?: boolean;
/**
* Skip lock renewal for this worker. If set to true, the lock will expire
* after lockDuration and moved back to the wait queue (if the stalled check is
* not disabled)
*
* @defaultValue false
*/
skipLockRenewal?: boolean;
/**
* Number of seconds to long poll for jobs when the queue is empty.
*
* @defaultValue 5
*/
drainDelay?: number;
/**
* Duration of the lock for the job in milliseconds. The lock represents that
* a worker is processing the job. If the lock is lost, the job will be eventually
* be picked up by the stalled checker and move back to wait so that another worker
* can process it again.
*
* @defaultValue 30000
*/
lockDuration?: number;
/**
* The time in milliseconds before the lock is automatically renewed.
*
* It is not recommended to modify this value, which is by default set to
* halv the lockDuration value, which is optimal for most use cases.
*/
lockRenewTime?: number;
/**
* This is an internal option that should not be modified.
*
* @defaultValue 15000
*/
runRetryDelay?: number;
/**
* More advanced options.
*/
settings?: AdvancedOptions;
/**
* Use Worker Threads instead of Child Processes.
* Note: This option can only be used when specifying
* a file for the processor argument.
*
* @defaultValue false
*/
useWorkerThreads?: boolean;
/**
* Telemetry Addon
*/
telemetry?: Telemetry;
}
export interface GetNextJobOptions {
block?: boolean;
}

Some files were not shown because too many files have changed in this diff Show More