qdone 2.0.2-alpha → 2.0.4-alpha
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/README.md +129 -41
- package/commonjs/src/defaults.js +2 -0
- package/commonjs/src/enqueue.js +2 -0
- package/npm-shrinkwrap.json +14118 -8334
- package/package.json +2 -2
- package/src/cli.js +2 -1
- package/src/defaults.js +2 -0
- package/src/enqueue.js +1 -0
package/README.md
CHANGED
|
@@ -25,11 +25,26 @@ qdone was inspired, in part, by experiences with [RQ](http://python-rq.org) in p
|
|
|
25
25
|
|
|
26
26
|
npm install -g qdone
|
|
27
27
|
|
|
28
|
+
If you're project is CommonJS, then you have to do a deep import of `qdone/commonjs`:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// Node CommonJS
|
|
32
|
+
const { enqueue } = require('qdone/commonjs')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If your project is ESM, you can import directly:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
// Node ESM
|
|
39
|
+
import { enqueue } from 'qdone'
|
|
40
|
+
````
|
|
41
|
+
|
|
28
42
|
## Examples
|
|
29
43
|
|
|
30
44
|
Enqueue a job and run it:
|
|
31
45
|
|
|
32
46
|
```bash
|
|
47
|
+
# Command line
|
|
33
48
|
$ qdone enqueue myQueue "echo hello world"
|
|
34
49
|
Enqueued job 030252de-8a3c-42c6-9278-c5a268660384
|
|
35
50
|
|
|
@@ -42,6 +57,16 @@ Looking for work on myQueue (https://sqs.us-east-1ld...)
|
|
|
42
57
|
stdout: hello world
|
|
43
58
|
```
|
|
44
59
|
|
|
60
|
+
```javascript
|
|
61
|
+
// Node ESM
|
|
62
|
+
import { enqueue } from 'qdone'
|
|
63
|
+
await enqueue('myQueue', 'echo hello world')
|
|
64
|
+
|
|
65
|
+
// Node CommonJS
|
|
66
|
+
const { enqueue } = require('qdone/commonjs')
|
|
67
|
+
enqueue('myQueue', 'echo hello world').then(console.log).catch(console.error)
|
|
68
|
+
```
|
|
69
|
+
|
|
45
70
|
Queues are automatically created when you use them:
|
|
46
71
|
|
|
47
72
|
```bash
|
|
@@ -53,11 +78,11 @@ Enqueued job d0077713-11e1-4de6-8f26-49ad51e008b9
|
|
|
53
78
|
|
|
54
79
|
Notice that qdone also created a failed queue. More on that later.
|
|
55
80
|
|
|
56
|
-
|
|
57
81
|
To queue many jobs at once, put a queue name and command on each line of
|
|
58
82
|
stdin or a file:
|
|
59
|
-
|
|
83
|
+
|
|
60
84
|
```bash
|
|
85
|
+
# Command line
|
|
61
86
|
$ qdone enqueue-batch - # use stdin
|
|
62
87
|
queue_0 echo hi
|
|
63
88
|
queue_1 echo hi
|
|
@@ -83,9 +108,28 @@ Enqueued job 5dfe1008-9a1e-41df-b3bc-614ec5f34660 request 10
|
|
|
83
108
|
Enqueued 10 jobs
|
|
84
109
|
```
|
|
85
110
|
|
|
111
|
+
```javascript
|
|
112
|
+
// Node ESM
|
|
113
|
+
import { enqueueBatch } from 'qdone'
|
|
114
|
+
await enqueueBatch(
|
|
115
|
+
[
|
|
116
|
+
{ queue: 'queue_1', command: 'echo hi' },
|
|
117
|
+
{ queue: 'queue_2', command: 'echo hi' },
|
|
118
|
+
{ queue: 'queue_3', command: 'echo hi' },
|
|
119
|
+
{ queue: 'queue_4', command: 'echo hi' },
|
|
120
|
+
{ queue: 'queue_5', command: 'echo hi' },
|
|
121
|
+
{ queue: 'queue_6', command: 'echo hi' },
|
|
122
|
+
{ queue: 'queue_7', command: 'echo hi' },
|
|
123
|
+
{ queue: 'queue_8', command: 'echo hi' },
|
|
124
|
+
{ queue: 'queue_9', command: 'echo hi' }
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
86
129
|
If you are using the same queue, requests to SQS will be batched:
|
|
87
130
|
|
|
88
131
|
```bash
|
|
132
|
+
# Command line
|
|
89
133
|
$ qdone enqueue-batch - # use stdin
|
|
90
134
|
queue_one echo hi
|
|
91
135
|
queue_one echo hi
|
|
@@ -107,6 +151,24 @@ Enqueued job 95567365... request 2 #
|
|
|
107
151
|
Enqueued 8 jobs
|
|
108
152
|
```
|
|
109
153
|
|
|
154
|
+
```javascript
|
|
155
|
+
// Node ESM
|
|
156
|
+
import { enqueueBatch } from 'qdone'
|
|
157
|
+
await enqueueBatch(
|
|
158
|
+
[
|
|
159
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
160
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
161
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
162
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
163
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
164
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
165
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
166
|
+
{ queue: 'queue_one', command: 'echo hi' },
|
|
167
|
+
{ queue: 'queue_one', command: 'echo hi' }
|
|
168
|
+
]
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
110
172
|
### Failed jobs
|
|
111
173
|
|
|
112
174
|
A command fails if it finishes with a non-zero exit code:
|
|
@@ -184,6 +246,7 @@ default SQS visibility timeout (30 seconds) as long as the job is still
|
|
|
184
246
|
running. You can see this when running a long job:
|
|
185
247
|
|
|
186
248
|
```bash
|
|
249
|
+
# Command line
|
|
187
250
|
$ qdone enqueue test "sleep 35"
|
|
188
251
|
Enqueued job d8e8927f-5e42-48ae-a1a8-b91e42700942
|
|
189
252
|
|
|
@@ -196,6 +259,12 @@ $ qdone worker test --kill-after 300
|
|
|
196
259
|
...
|
|
197
260
|
```
|
|
198
261
|
|
|
262
|
+
```javascript
|
|
263
|
+
// Node ESM
|
|
264
|
+
import { enqueue } from 'qdone'
|
|
265
|
+
await enqueue('test', 'sleep 25', { killAfter: 300 })
|
|
266
|
+
```
|
|
267
|
+
|
|
199
268
|
The SQS API call to extend this timeout (`ChangeMessageVisibility`) is called
|
|
200
269
|
at the halfway point before the message becomes visible again. The timeout
|
|
201
270
|
doubles every subsequent call but never exceeds `--kill-after`.
|
|
@@ -252,9 +321,9 @@ The `equeue` and `enqueue-batch` commands can create FIFO queues with limited fe
|
|
|
252
321
|
|
|
253
322
|
Using the `--fifo` option with `enqueue` or `enqueue-batch`:
|
|
254
323
|
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
-
|
|
324
|
+
- Causes any new queues to be created as FIFO queues
|
|
325
|
+
- Causes the `.fifo` suffix to be appended to any queue names that do not explicitly have them
|
|
326
|
+
- Causes failed queues to take the form `${name}_failed.fifo`
|
|
258
327
|
|
|
259
328
|
Using the `--group-id` option with `enqueue` or `enqueue-batch` implies that:
|
|
260
329
|
|
|
@@ -270,8 +339,8 @@ Enqueue limitations:
|
|
|
270
339
|
|
|
271
340
|
Using the `--fifo` option with `worker`:
|
|
272
341
|
|
|
273
|
-
-
|
|
274
|
-
-
|
|
342
|
+
- Causes the `.fifo` suffix to be appended to any queue names that do not explicitly have them
|
|
343
|
+
- Causes the worker to only listen to queues with a `.fifo` suffix when wildcard names are specified (e.g. `test_*` or `*`)
|
|
275
344
|
|
|
276
345
|
Worker limitations:
|
|
277
346
|
|
|
@@ -300,7 +369,7 @@ The output examples in this readme assume you are running qdone from an interact
|
|
|
300
369
|
|
|
301
370
|
Each field in the above JSON except `event` and `timestamp` is optional and only appears when it contains data. Note that log events other than `JOB_FAILED` may be added in the future. Also note that warnings and errors not in the above JSON format will appear on stderr.
|
|
302
371
|
|
|
303
|
-
## Shutdown Behavior
|
|
372
|
+
## Worker Shutdown Behavior
|
|
304
373
|
|
|
305
374
|
Send a SIGTERM or SIGINT to qdone and it will exit successfully after any running jobs complete. A second SIGTERM or SIGINT will immediately kill the entire process group, including any running jobs.
|
|
306
375
|
|
|
@@ -356,11 +425,11 @@ Example IAM policy allowing qdone to use queues with its prefix in any region:
|
|
|
356
425
|
"sqs:GetQueueAttributes",
|
|
357
426
|
"sqs:GetQueueUrl",
|
|
358
427
|
"sqs:SendMessage",
|
|
359
|
-
"sqs:SendMessageBatch",
|
|
360
428
|
"sqs:ReceiveMessage",
|
|
361
429
|
"sqs:DeleteMessage",
|
|
362
430
|
"sqs:CreateQueue",
|
|
363
|
-
"sqs:ChangeMessageVisibility"
|
|
431
|
+
"sqs:ChangeMessageVisibility",
|
|
432
|
+
"sqs:TagQueue"
|
|
364
433
|
],
|
|
365
434
|
"Effect": "Allow",
|
|
366
435
|
"Resource": "arn:aws:sqs:*:YOUR_ACCOUNT_ID:qdone_*"
|
|
@@ -399,53 +468,72 @@ not possible to narrow the scope):
|
|
|
399
468
|
|
|
400
469
|
Commands
|
|
401
470
|
|
|
402
|
-
enqueue Enqueue a single command
|
|
403
|
-
enqueue-batch Enqueue multiple commands from stdin or a file
|
|
404
|
-
worker Execute work on one or more queues
|
|
471
|
+
enqueue Enqueue a single command
|
|
472
|
+
enqueue-batch Enqueue multiple commands from stdin or a file
|
|
473
|
+
worker Execute work on one or more queues
|
|
474
|
+
idle-queues Write a list of idle queues to stdout
|
|
475
|
+
monitor Monitor multiple queues at once
|
|
405
476
|
|
|
406
477
|
Global Options
|
|
407
478
|
|
|
408
|
-
--prefix string
|
|
409
|
-
--fail-suffix string
|
|
410
|
-
--region string
|
|
411
|
-
-q, --quiet
|
|
412
|
-
-v, --verbose
|
|
413
|
-
-V, --version
|
|
414
|
-
--
|
|
479
|
+
--prefix string Prefix to place at the front of each SQS queue name [default: qdone_]
|
|
480
|
+
--fail-suffix string Suffix to append to each queue to generate fail queue name [default: _failed]
|
|
481
|
+
--region string AWS region for Queues [default: us-east-1]
|
|
482
|
+
-q, --quiet Turn on production logging. Automatically set if stderr is not a tty.
|
|
483
|
+
-v, --verbose Turn on verbose output. Automatically set if stderr is a tty.
|
|
484
|
+
-V, --version Show version number
|
|
485
|
+
--cache-uri string URL to caching cluster. Only redis://... currently supported.
|
|
486
|
+
--cache-prefix string Prefix for all keys in cache. [default: qdone:]
|
|
487
|
+
--cache-ttl-seconds number Number of seconds to cache GetQueueAttributes calls. [default: 10]
|
|
488
|
+
--help Print full help message.
|
|
489
|
+
--sentry-dsn string Optional Sentry DSN to track unhandled errors.
|
|
415
490
|
|
|
416
491
|
### Enqueue Usage
|
|
417
492
|
|
|
418
493
|
usage: qdone enqueue [options] <queue> <command>
|
|
419
494
|
usage: qdone enqueue-batch [options] <file...>
|
|
420
495
|
|
|
421
|
-
`<file...>` can be one ore more filenames or - for stdin
|
|
496
|
+
`<file...>` can be one ore more filenames or - for stdin
|
|
422
497
|
|
|
423
498
|
Options
|
|
424
499
|
|
|
425
|
-
-f, --fifo
|
|
426
|
-
-g, --group-id string
|
|
427
|
-
|
|
428
|
-
--
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
--
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
--
|
|
439
|
-
-
|
|
440
|
-
-
|
|
441
|
-
|
|
442
|
-
--
|
|
500
|
+
-f, --fifo Create new queues as FIFOs
|
|
501
|
+
-g, --group-id string FIFO Group ID to use for all messages enqueued in current command.
|
|
502
|
+
Defaults to a string unique to this invocation.
|
|
503
|
+
--group-id-per-message Use a unique Group ID for every message, even messages in the same
|
|
504
|
+
batch.
|
|
505
|
+
--deduplication-id string A Message Deduplication ID to give SQS when sending a message. Use
|
|
506
|
+
this option if you are managing retries outside of qdone, and make
|
|
507
|
+
sure the ID is the same for each retry in the deduplication window.
|
|
508
|
+
Defaults to a string unique to this invocation.
|
|
509
|
+
--message-retention-period number Number of seconds to retain jobs (up to 14 days). [default: 1209600]
|
|
510
|
+
-d, --delay number Delays delivery of each message by the given number of seconds
|
|
511
|
+
(up to 900 seconds, or 15 minutes). Defaults to immediate delivery
|
|
512
|
+
(no delay).
|
|
513
|
+
--dlq Send messages from the failed queue to a DLQ.
|
|
514
|
+
--dql-suffix string Suffix to append to each queue to generate DLQ name [default: _dead]
|
|
515
|
+
--dql-after string Drives message to the DLQ after this many failures in the failed
|
|
516
|
+
queue. [default: 3]
|
|
517
|
+
--tag string[] Adds an AWS tag to queue creation. Use the format Key=Value. Can
|
|
518
|
+
specify multiple times.
|
|
519
|
+
--prefix string Prefix to place at the front of each SQS queue name [default: qdone_]
|
|
520
|
+
--fail-suffix string Suffix to append to each queue to generate fail queue name
|
|
521
|
+
[default: _failed]
|
|
522
|
+
--region string AWS region for Queues [default: us-east-1]
|
|
523
|
+
-q, --quiet Turn on production logging. Automatically set if stderr is not a tty.
|
|
524
|
+
-v, --verbose Turn on verbose output. Automatically set if stderr is a tty.
|
|
525
|
+
-V, --version Show version number
|
|
526
|
+
--cache-uri string URL to caching cluster. Only redis://... currently supported.
|
|
527
|
+
--cache-prefix string Prefix for all keys in cache. [default: qdone:]
|
|
528
|
+
--cache-ttl-seconds number Number of seconds to cache GetQueueAttributes calls. [default: 10]
|
|
529
|
+
--help Print full help message.
|
|
530
|
+
--sentry-dsn string Optional Sentry DSN to track unhandled errors.
|
|
443
531
|
|
|
444
532
|
### Worker Usage
|
|
445
533
|
|
|
446
534
|
usage: qdone worker [options] <queue...>
|
|
447
535
|
|
|
448
|
-
`<queue...>` one or more queue names to listen on for jobs
|
|
536
|
+
`<queue...>` one or more queue names to listen on for jobs
|
|
449
537
|
|
|
450
538
|
If a queue name ends with the * (wildcard) character, worker will listen on all queues that match the name up-to the wildcard. Place arguments like this inside quotes to keep the shell from globbing local files.
|
|
451
539
|
|
|
@@ -454,7 +542,7 @@ If a queue name ends with the * (wildcard) character, worker will listen on all
|
|
|
454
542
|
-k, --kill-after number Kill job after this many seconds [default: 30]
|
|
455
543
|
-w, --wait-time number Listen at most this long on each queue [default: 20]
|
|
456
544
|
--include-failed When using '*' do not ignore fail queues.
|
|
457
|
-
--active-only Listen only to queues with pending messages.
|
|
545
|
+
--active-only Listen only to queues with pending messages.
|
|
458
546
|
--drain Run until no more work is found and quit. NOTE: if used with
|
|
459
547
|
--wait-time 0, this option will not drain queues.
|
|
460
548
|
--prefix string Prefix to place at the front of each SQS queue name [default: qdone_]
|
package/commonjs/src/defaults.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.defaults = Object.freeze({
|
|
|
26
26
|
deduplicationId: (0, uuid_1.v1)(),
|
|
27
27
|
messageRetentionPeriod: 1209600,
|
|
28
28
|
delay: 0,
|
|
29
|
+
failDelay: 0,
|
|
29
30
|
dlq: false,
|
|
30
31
|
dlqSuffix: '_dead',
|
|
31
32
|
dlqAfter: 3,
|
|
@@ -73,6 +74,7 @@ function getOptionsWithDefaults(options) {
|
|
|
73
74
|
deduplicationId: options.deduplicationId || options['deduplication-id'] || exports.defaults.deduplicationId,
|
|
74
75
|
messageRetentionPeriod: options.messageRetentionPeriod || options['message-retention-period'] || exports.defaults.messageRetentionPeriod,
|
|
75
76
|
delay: options.delay || exports.defaults.delay,
|
|
77
|
+
failDelay: options.failDelay || options['fail-delay'] || exports.defaults.failDelay,
|
|
76
78
|
dlq: dlq || exports.defaults.dlq,
|
|
77
79
|
dlqSuffix: options.dlqSuffix || options['dlq-suffix'] || exports.defaults.dlqSuffix,
|
|
78
80
|
dlqAfter: options.dlqAfter || options['dlq-after'] || exports.defaults.dlqAfter,
|
package/commonjs/src/enqueue.js
CHANGED