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
Sanitized options #504
Sanitized options #504
Changes from 7 commits
2fa99d5
03cabe5
e9784d3
9e882c3
5271193
2a215fd
515d6f6
80a1507
b9c420a
c40f649
fe97c07
81639b9
d5abe9f
616249c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
v.3.0.0-alpha.2 | ||
=============== | ||
|
||
- Eliminated possible memory leak #503 | ||
|
||
v.3.0.0-alpha.1 | ||
=============== | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,10 +78,10 @@ Quick Guide | |
```javascript | ||
var Queue = require('bull'); | ||
|
||
var videoQueue = Queue('video transcoding', 6379, '127.0.0.1'); | ||
var audioQueue = Queue('audio transcoding', 6379, '127.0.0.1'); | ||
var imageQueue = Queue('image transcoding', 6379, '127.0.0.1'); | ||
var pdfQueue = Queue('pdf transcoding', 6379, '127.0.0.1'); | ||
var videoQueue = Queue('video transcoding', {redis: {port: 6379, host: '127.0.0.1'}}); | ||
var audioQueue = Queue('audio transcoding', 'redis://127.0.0.1:6379'); | ||
var imageQueue = Queue('image transcoding'); | ||
var pdfQueue = new Queue('pdf transcoding'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the examples above too, for consistency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. My idea was to show different ways to instantiate in the examples. I could clarify with a comment instead. I like to be able to instantiate without new, but maybe this is not a best practice anymore. |
||
|
||
videoQueue.process(function(job, done){ | ||
|
||
|
@@ -247,7 +247,7 @@ var | |
cluster = require('cluster'); | ||
|
||
var numWorkers = 8; | ||
var queue = Queue("test concurrent queue", 6379, '127.0.0.1'); | ||
var queue = Queue("test concurrent queue"); | ||
|
||
if(cluster.isMaster){ | ||
for (var i = 0; i < numWorkers; i++) { | ||
|
@@ -290,19 +290,15 @@ This can be achieved using the "createClient" option in the queue constructor: | |
subscriber = new redis(); | ||
|
||
var opts = { | ||
redis: { | ||
opts: { | ||
createClient: function(type){ | ||
switch(type){ | ||
case 'client': | ||
return client; | ||
case 'subscriber': | ||
return subscriber; | ||
default: | ||
return new redis(); | ||
} | ||
createClient: function(type, opts){ | ||
switch(type){ | ||
case 'client': | ||
return client; | ||
case 'subscriber': | ||
return subscriber; | ||
default: | ||
return new redis(opts); | ||
} | ||
} | ||
} | ||
} | ||
var queueFoo = new Queue('foobar', opts); | ||
|
@@ -390,34 +386,40 @@ listened by some other service that stores the results in a database. | |
|
||
### Queue | ||
|
||
```ts | ||
Queue(queueName: string, redisPort: number, redisHost: string, redisOpts?: RedisOpts): Queue | ||
``` | ||
```ts | ||
Queue(queueName: string, redisConnectionString: string, redisOpts? RedisOpts): Queue | ||
```typescript | ||
Queue(queueName: string, redisConnectionString?: string, opts: QueueOptions): Queue | ||
``` | ||
|
||
This is the Queue constructor. It creates a new Queue that is persisted in | ||
Redis. Everytime the same queue is instantiated it tries to process all the | ||
old jobs that may exist from a previous unfinished session. | ||
|
||
If no connection string or options passed, the queue will use ioredis default connection | ||
settings. | ||
|
||
__Arguments__ | ||
|
||
```javascript | ||
queueName {String} A unique name for this Queue. | ||
redisPort {Number} A port where redis server is running. | ||
redisHost {String} A host specified as IP or domain where redis is running. | ||
redisOptions {Object} Options to pass to the redis client. https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options | ||
```typescript | ||
queueName: string, // A unique name for this Queue. | ||
redisConnectionString?: string, // string A connection string containing the redis server host, port and (optional) authentication. | ||
opts?: QueueOptions, // Options to pass to the redis client. https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options | ||
``` | ||
|
||
Alternatively, it's possible to pass a connection string to create a new queue. | ||
|
||
__Arguments__ | ||
|
||
```javascript | ||
queueName {String} A unique name for this Queue. | ||
redisConnectionString {String} A connection string containing the redis server host, port and (optional) authentication. | ||
redisOptions {Object} Options to pass to the redis client. https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options | ||
```typescript | ||
interface QueueOptions { | ||
prefix?: string = 'bull', | ||
redis : RedisOpts, // ioredis defaults | ||
createClient?: (type: enum('client', 'subscriber'), redisOpts?: RedisOpts) => redisClient, | ||
|
||
// Advanced settings | ||
settings?: QueueSettings { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm working on a PR to document these in more detail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
lockDuration?: number = 5000, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about defaulting the lock to 30 seconds? My thoughts:
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it is ok to have a larger value as default, specially now when it can be configured. I also look forward #488, which for long duration jobs should work much better. |
||
stalledInterval?: number = 5000, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per above comment, I think this should be moved to 30sec also. It doesn't do much good to make it a lot less than the lock time. Also note that since this is run once per process, if it was set to 30sec here, across 6+ worker processes it'd get called about every 5sec anyways. |
||
maxStalledCount?: number = 1, // The maximum number of times a job can be recovered from the 'stalled' state | ||
guardInterval?: number = 5000, | ||
retryProcessDelay?: number = 5000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this in #507 |
||
} | ||
} | ||
``` | ||
|
||
--------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be clearer to use the redis string version here, eg
redis://127.0.0.1:6379
, since the documentation lists theredisConnectionString
as the second option (albeit optional - but some people might not notice that)