Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bull: Add types to some private functions #27816

Merged
merged 2 commits into from Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions types/bull/index.d.ts
Expand Up @@ -9,6 +9,7 @@
// David Koblas <https://github.com/koblas>
// Bond Akinmade <https://github.com/bondz>
// Wuha Team <https://github.com/wuha-team>
// Alec Brunelle <https://github.com/aleccool213>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

Expand Down
32 changes: 31 additions & 1 deletion types/bull/v2/index.d.ts
Expand Up @@ -54,6 +54,24 @@ declare module "bull" {
* since pubsub does not give any guarantees.
*/
finished(): Promise<void>;

/**
* Moves a job to the `completed` queue. Pulls a job from 'waiting' to
* 'active' and returns a tuple containing the next jobs data and id. If no
* job is in the `waiting` queue, returns null.
* @param returnValue The jobs success message.
* @param ignoreLock True when wanting to ignore the redis lock on this job.
* @returns Contains the next jobs data and id or null if job left in 'waiting' queue.
*/
moveToCompleted(returnValue: string, ignoreLock: boolean): Promise<string[] | null>;

/**
* Moves a job to the failed queue.
* @param errorInfo The jobs error message.
* @param ignoreLock True when wanting to ignore the redis lock on this job.
* @returns void
*/
moveToFailed(errorInfo: ErrorMessage, ignoreLock: boolean): Promise<void>;
}

export interface Backoff {
Expand Down Expand Up @@ -204,7 +222,7 @@ declare module "bull" {
* Returns a promise that will return the job instance associated with the jobId parameter.
* If the specified job cannot be located, the promise callback parameter will be set to null.
*/
getJob(jobId: string): Promise<Job>;
getJob(jobId: string): Promise<Job | null>;

/**
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
Expand All @@ -217,6 +235,18 @@ declare module "bull" {
* 'ready', 'error', 'activ', 'progress', 'completed', 'failed', 'paused', 'resumed', 'cleaned'
*/
on(eventName: string, callback: EventCallback): void;

/**
* Moves the next job from 'waiting' to 'active'.
* Sets the processedOn timestamp to the current datetime.
* @param jobId If specified, will move a specific job from 'waiting' to 'active',
* @returns Returns the job moved from waiting to active queue.
*/
getNextJob:(jobId?: string) => Promise<Job | null>;
}

interface ErrorMessage {
message: string;
}

interface EventCallback {
Expand Down