While attempting to use setTimeout
to perform rate limiting on a monq
worker, why is the worker not being throttled?
worker
does not wait for 10 seconds before executing setTimeout()
. Why is this and how can we get it to delay the call to foo()
?
var monq = require('monq')
var client = monq('localhost/mydb')
var worker = client.worker(['general'])
worker.register({
test: function(params, callback) {
try {
setTimeout(foo(params, callback), 10000)
} catch(err) {
callback(err)
}
}
})
foo = function(params, callback) {
console.log('Hello world')
callback()
}