From 7fede780bba00fbbe9ae83d9b7aa0e067f2ca8fa Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Fri, 21 Feb 2020 16:21:11 -0500 Subject: [PATCH 1/7] chore(Typescript): Update Typescript declarations and add documentation --- README.md | 21 ++++++++++++++++++++- index.d.ts | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 485909d3..90219ee8 100644 --- a/README.md +++ b/README.md @@ -583,6 +583,25 @@ process.on('uncaughtException', async () => { process.exit(1); }); ``` +#### Queue#isRunning() + +Returns `true` unless the Queue is shutting down due to a call to `Queue#close()`; + +#### Queue#ready([cb]) + +Promise resolves to the queue (or callback is called wth `null` argument) when the queue (and Redis) are ready for jobs. Learn more about `'ready'` in [Queue Local Events](#queue-local-events). + +```js +const Queue = require('bee-queue'); +const queue = new Queue('example'); +queue.ready() + .then(async queue => { + console.log('isRunning:', queue.isRunning()); + const checkHealth = await queue.checkHealth(); + console.log('checkHealth:', JSON.stringify(checkHealth)); + }) + .catch(err => console.log('unreadyable', err)); +``` #### Queue#removeJob(jobId, [cb]) @@ -686,7 +705,7 @@ The job has sent a [progress report](#jobreportprogressn) of `progress` percent. ### Methods -Each Job can be configured with the commands `.setId(id)`, `.retries(n)`, `.backoff(strategy, delayFactor)`, `.delayUntil(date|timestamp)`, and `.timeout(ms)`. +Each Job can be configured with the chainable commands `.setId(id)`, `.retries(n)`, `.backoff(strategy, delayFactor)`, `.delayUntil(date|timestamp)`, and `.timeout(ms)`. #### Job#setId(id) diff --git a/index.d.ts b/index.d.ts index 0f7517b6..f274c7a5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -25,7 +25,7 @@ declare class BeeQueue { getJob(jobId: string, cb: (job: BeeQueue.Job) => void): void; getJob(jobId: string): Promise; - + getJobs(type: string, page: BeeQueue.Page, cb: (jobs: BeeQueue.Job[]) => void): void; getJobs(type: string, page: BeeQueue.Page): Promise; @@ -45,6 +45,11 @@ declare class BeeQueue { close(timeout?: number | null): Promise; close(timeout: number | undefined | null, cb: () => void): void; + isRunning(): boolean; + + ready(): Promise; + ready(cb: () => void): void; + removeJob(jobId: string): Promise; removeJob(jobId: string, cb: () => void): void From 3733df33567f810bf5447230cf9a6177d2b03c18 Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 21:48:12 -0500 Subject: [PATCH 2/7] Update README.md Co-Authored-By: Eli Skeggs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90219ee8..e0fb0851 100644 --- a/README.md +++ b/README.md @@ -585,7 +585,7 @@ process.on('uncaughtException', async () => { ``` #### Queue#isRunning() -Returns `true` unless the Queue is shutting down due to a call to `Queue#close()`; +Returns `true` unless the Queue is shutting down due to a call to `Queue#close()`. #### Queue#ready([cb]) From b8be2db166ef7d62b96be2333b5c8f31d7a707d3 Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 21:48:20 -0500 Subject: [PATCH 3/7] Update README.md Co-Authored-By: Eli Skeggs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0fb0851..f43d1678 100644 --- a/README.md +++ b/README.md @@ -598,7 +598,7 @@ queue.ready() .then(async queue => { console.log('isRunning:', queue.isRunning()); const checkHealth = await queue.checkHealth(); - console.log('checkHealth:', JSON.stringify(checkHealth)); + console.log('checkHealth:', checkHealth); }) .catch(err => console.log('unreadyable', err)); ``` From b645d424088957939dd66de71f3be6962d1aad6b Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 21:48:37 -0500 Subject: [PATCH 4/7] Update README.md Co-Authored-By: Eli Skeggs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f43d1678..3c34b11e 100644 --- a/README.md +++ b/README.md @@ -600,7 +600,7 @@ queue.ready() const checkHealth = await queue.checkHealth(); console.log('checkHealth:', checkHealth); }) - .catch(err => console.log('unreadyable', err)); + .catch((err) => console.log('unreadyable', err)); ``` #### Queue#removeJob(jobId, [cb]) From 0b333f16690800eb471ad9d7065e5e3bd514464b Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 21:58:44 -0500 Subject: [PATCH 5/7] Update index.d.ts Co-Authored-By: Eli Skeggs --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index f274c7a5..4324ebe6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -48,7 +48,7 @@ declare class BeeQueue { isRunning(): boolean; ready(): Promise; - ready(cb: () => void): void; + ready(cb: () => void): Promise; removeJob(jobId: string): Promise; removeJob(jobId: string, cb: () => void): void From ead5dfa18ccd85bdb33125df05af052582984912 Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 21:59:44 -0500 Subject: [PATCH 6/7] Update README.md Co-Authored-By: Eli Skeggs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c34b11e..59f9d96f 100644 --- a/README.md +++ b/README.md @@ -595,7 +595,7 @@ Promise resolves to the queue (or callback is called wth `null` argument) when t const Queue = require('bee-queue'); const queue = new Queue('example'); queue.ready() - .then(async queue => { + .then(async (queue) => { console.log('isRunning:', queue.isRunning()); const checkHealth = await queue.checkHealth(); console.log('checkHealth:', checkHealth); From bf910e97b2f0466da7785d85b1ff2fd1cf186052 Mon Sep 17 00:00:00 2001 From: Hugh Secker-Walker Date: Sat, 7 Mar 2020 22:44:04 -0500 Subject: [PATCH 7/7] fix(index.d.ts): Fix declaration for Job.on(succeeded) callback -- Resolves issue #138 --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 4324ebe6..47842647 100644 --- a/index.d.ts +++ b/index.d.ts @@ -83,7 +83,7 @@ declare namespace BeeQueue { queue: BeeQueue; progress: number; - on(ev: "succeeded", fn: (err: Error) => void): this; + on(ev: "succeeded", fn: (result: any) => void): this; on(ev: "retrying", fn: (err: Error) => void): this; on(ev: "failed", fn: (err: Error) => void): this; on(ev: "progress", fn: (progress: number) => void): this;