-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
@bradvogel @chuym new PR you may be interested of. This is a small one, but will break backwards compatibility. |
Awesome! Will review shortly |
README.md
Outdated
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'}}); |
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 the redisConnectionString
as the second option (albeit optional - but some people might not notice that)
README.md
Outdated
var videoQueue = Queue('video transcoding', {redis: {port: 6379, host: '127.0.0.1'}}); | ||
var audioQueue = Queue('audio transcoding'); | ||
var imageQueue = Queue('image transcoding'); | ||
var pdfQueue = Queue('pdf transcoding'); |
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.
I think it's clearer to use use new
in the examples, e.g. new Queue('pdf transcoding');
, so it's clearer that an object instance is returned.
README.md
Outdated
var imageQueue = Queue('image transcoding'); | ||
var pdfQueue = Queue('pdf transcoding'); | ||
var pdfQueue = new Queue('pdf transcoding'); |
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.
for the examples above too, for consistency.
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.
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.
README.md
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
README.md
Outdated
stalledInterval?: number = 5000, | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should include lockRenewTime
?
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.
Added this in #507
…frequently asked question in various Github issues).
Created PR #507 into this PR. Let me know how that looks. The readme is coming along nicely! |
README.md
Outdated
|
||
// Advanced settings | ||
settings?: QueueSettings { | ||
lockDuration?: number = 5000, |
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.
What do you think about defaulting the lock to 30 seconds? My thoughts:
- A lot of people complain about jobs being double processed currently. So there must be a lot of poorly written job processor code out there that stalls the event loop :). Or folks, like me, forget that we're running our code on tiny instances in the cloud where the CPU is so limited that a tiny bit of JS work will max the CPU. A 30sec timeout would give a bit more buffer. At least until we figure out a generic solution like [Feature] Support for running jobs in child processes #488.
- An expired lock (due to event loop stalling) is quite fatal now that we check the lock prior to moving the job to the
completed
orfailed
(previously we would still move it if there wasn't a lock). So if a long running job (let's say 2min) stalls the event loop for even just 5sec, it means that the job is basically tombstoned at that point. It might still continue processing, but another worker would have likely picked it up as a stalled job and double-processed it. Or if it doesn't happen to get picked up as stalled, when it finally completes it still won't be moved tocompleted
because it lost the lock at one time. - The tradeoff is that it will take longer for jobs to be considered 'stalled'. So instead waiting max 5sec to find out if a job was stalled, we'd wait 30sec. I think this is generally OK and that most people aren't running jobs that are that time-sensitive. Actual stalled jobs [due to process crashes] should be extremely rare anyways.
What do you think?
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.
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.
README.md
Outdated
// Advanced settings | ||
settings?: QueueSettings { | ||
lockDuration?: number = 5000, | ||
stalledInterval?: number = 5000, |
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.
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.
This PR aims to cleanup the constructor of the Queue and make the options more sane. Also support for configuring a lot of settings that were constants before.