burstable / node-beanstalkd-worker Goto Github PK
View Code? Open in Web Editor NEWHigh level library for running beanstalkd workers in Node.js
License: MIT License
High level library for running beanstalkd workers in Node.js
License: MIT License
Hi. Is There a way to add the job data without the property "payload" ? This makes it possibly incompatible if you want to use this library together with others that puts data objects ( or pure strings ? ) directly to the job contents.
If I spawn a job with the lib it looks like this:
{
"payload":{
"ax":"xyz"
}
}
but I expect it like this:
{
"ax":"xyz"
}
Code is from your example:
worker.spawn(tube, {
ax: "xyz" // job payload/values
}, {
delay: 0,
priority: 1000,
timeout: 10 * 60 * 1000 // ms
}).then(function (job) {
console.log(job.id);
});
The following code results in (node:18780) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): undefined
when validate(data)
throws an error. It's running in Node v8.1.4.
worker.handle(`validation`, data => {
return new Promise(res => {
res(validate(data))
})
})
Because the worker is expecting either a resolved or rejected Promise, my assumption would be that rejected promises are handled by the library and registered as failures. If that's not the case, where should these rejections be managed?
Hi, I'm getting this error a couple of minutes after successfully starting a worker process:
/home/me/node_modules/bluebird/js/main/promise.js:783
promise._reject(value, carriedStackTrace);
^
TypeError: Cannot read property '_reject' of undefined
at Promise._settlePromiseAt (/home/me/node_modules/bluebird/js/main/promise.js:783:17)
at Promise._settlePromises (/home/me/node_modules/bluebird/js/main/promise.js:884:14)
at Async._drainQueue (/home/me/node_modules/bluebird/js/main/async.js:98:12)
at Async._drainQueues (/home/me/node_modules/bluebird/js/main/async.js:103:10)
at Async.drainQueues (/home/me/node_modules/bluebird/js/main/async.js:37:14)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
I'm running a simple worker process in a docker image: FROM node:8.8-alpine
.
My setup is about as simple as it could be, but I can't figure out how to keep a worker process running. I've dug into the source code looking for some kind of keepalive
and haven't seen anything, and as far as I can tell, the loop
function should be running.
Here is my code:
const queue = new BeanstalkdWorker(config.beanstalkd.host, config.beanstalkd.port),
// ----------------------- WEB APP -----------------------
async function run(project) {
const job = await queue.spawn(`validation`, project)
return {id: job.id}
}
export default run
// ----------------------- WORKER -----------------------
const COMMAND = `node ${__filename}`
const IS_WORKER = `${process.argv0} ${process.argv.slice(1).join(` `)}` === COMMAND
if (IS_WORKER) {
queue.handle(`validation`, project => Promise.resolve(validate(project)))
queue.start()
}
And here is the output from DEBUG=* node ./validate.js
beanstalkd-worker:validation Starting watchers +0ms
beanstalkd connecting to 127.0.0.1:11300 +0ms
beanstalkd connected to 127.0.0.1:11300 +326ms
beanstalkd Sent command "watch validation" +11ms
beanstalkd Sent command "ignore default" +2ms
beanstalkd-worker:validation Reserving job, timeout: 30000 +341ms
After the "Reserving job" debug output, the process ends. Any suggestions would be great, thanks for your time!
Moving from wrong repo burstable/node-beanstalkd-client#6
This client currently does not handle disconnects, be it just a network error or the complete node fails.
Either throw on connection failure or reconnect.
it breaks completely, every subsequent request just throws errors that it can't connect to the server even though it is running again. Only restarting the application helps.
so once i make a call and no server is available it first throws errors and after that it wont stop throwing on subsequent request. If I however do not make a request while the server is down and it is back available again before the next, for some strange reasons everything works.
We talk by the way about spawning, the handler just silently dies and does nothing anymore forever.
The readme says this:
Keep in mind that worker will spawn a connection equal to width * amount of tubes
Would you mind elaborating what "width" is?
Hi,
This project is great but I skipped it numerous times while searching for a decent beanstalkd
client, because I thought this was only for the job consumer (worker) side. In fact, this can actually put jobs in the queue, so generally speaking it is more than a worker. It's both a job producer and consumer, but I didn't realize that.
Please consider improving the description of the project, to show that it covers the whole producer-consumer cycle. I think more people would use it then.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.