Skip to content

Commit

Permalink
[bulll] add missing variable, function definitions (DefinitelyTyped#3…
Browse files Browse the repository at this point in the history
…6652)

* add missing functions definitions

* add missing function def

* change log() return value

* update bull version

* add client to Queue

* typo

* add github reference and comment

* lint

* remove unnecessary code links

* modify comments for JSDoc

* remove redundant type info

* remove redundant type info
  • Loading branch information
hados99 authored and andrewbranch committed Jul 9, 2019
1 parent affe9d1 commit 575279d
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
18 changes: 18 additions & 0 deletions types/bull/bull-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,34 @@ const audioQueue = new Queue('audio transcoding', {
});
const imageQueue: Queue.Queue<{ image: string }> = new Queue('image transcoding');

videoQueue.getWorkers();
videoQueue.setWorkerName();
videoQueue.base64Name();
videoQueue.clientName();
videoQueue.parseClientList('');

videoQueue.process((job, done) => {
// job.data contains the custom data passed when the job was created
// job.jobId contains id of this job.

// job.opts contains the options that were passed to the job
job.opts;

job.queue;
job.queue.client;

// transcode video asynchronously and report progress
job.progress(42);

job.log('loglog');
job.isCompleted();
job.isFailed();
job.isDelayed();
job.isActive();
job.isWaiting();
job.isPaused();
job.isStuck();

// call done when finished
done();

Expand Down
83 changes: 82 additions & 1 deletion types/bull/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for bull 3.5
// Type definitions for bull 3.10
// Project: https://github.com/OptimalBits/bull
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Cameron Crothers <https://github.com/JProgrammer>
Expand All @@ -14,6 +14,7 @@
// Kjell-Morten Bratsberg Thorsen <https://github.com/kjellmorten>
// Christian D. <https://github.com/pc-jedi>
// Silas Rech <https://github.com/lenovouser>
// DoYoung Ha <https://github.com/hados99>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

Expand Down Expand Up @@ -172,6 +173,48 @@ declare namespace Bull {
*/
progress(value: any): Promise<void>;

/**
* Logs one row of log data.
*
* @param row String with log data to be logged.
*/
log(row: string): Promise<any>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is completed
*/
isCompleted(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is failed
*/
isFailed(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is delayed
*/
isDelayed(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is active
*/
isActive(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is wait
*/
isWaiting(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is paused
*/
isPaused(): Promise<boolean>;

/**
* Returns a promise resolving to a boolean which, if true, current job's state is stuck
*/
isStuck(): Promise<boolean>;

/**
* Returns a promise resolving to the current job's status.
* Please take note that the implementation of this method is not very efficient, nor is
Expand Down Expand Up @@ -402,6 +445,11 @@ declare namespace Bull {
*/
name: string;

/**
* Queue client (used to add jobs, pause queues, etc);
*/
client: Redis.Redis;

/**
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs.
* This replaces the `ready` event emitted on Queue in previous verisons.
Expand Down Expand Up @@ -627,6 +675,12 @@ declare namespace Bull {
*/
getJobs(types: string[], start?: number, end?: number, asc?: boolean): Promise<Array<Job<T>>>;

/**
* Returns a object with the logs according to the start and end arguments. The returned count
* value is the total amount of logs, useful for implementing pagination.
*/
getJobLogs(jobId: string, start?: number, end?: number): Promise<{ logs: string[], count: number }>;

/**
* Returns a promise that resolves with the job counts for the given queue.
*/
Expand Down Expand Up @@ -755,6 +809,33 @@ declare namespace Bull {
* Array of Redis clients the queue uses
*/
clients: Redis.Redis[];

/**
* Set clientName to Redis.client
*/
setWorkerName(): Promise<any>;

/**
* Returns Redis clients array which belongs to current Queue
*/
getWorkers(): Promise<Redis.Redis[]>;

/**
* Returns Queue name in base64 encoded format
*/
base64Name(): string;

/**
* Returns Queue name with keyPrefix (default: 'bull')
*/
clientName(): string;

/**
* Returns Redis clients array which belongs to current Queue from string with all redis clients
*
* @param list String with all redis clients
*/
parseClientList(list: string): Redis.Redis[];
}

type EventCallback = () => void;
Expand Down

0 comments on commit 575279d

Please sign in to comment.