beanstalk-promises v1.0.0
beanstalk-promises
Promise wraper for fivebeans client so you can use promises instead of callbacks and await them
Quick start
const Beanstalk = require('beanstalk-promises')
async function main () {
let client = new Beanstalk()
await client.connect('127.0.0.1', 11300, 1000)
await client.watchTube('test')
let job = await client.getJob()
await client.quit()
}
main()Functions
constructor(debug, default_ttl)Create new instance of beanstalk-promises client.- If
debugis true (or if it just exist) it will print debug messages. default_ttlis a parameter that sets how long job could be reserved.
- If
.connect(host, port, reconnect)reconnectis a number in miliseconds, client will reconnect to beanstalk after it if something happens. Set0to disable.
.quit()Disconnects the client, no reconnect..watchTube(tube)return number of watched tubestubename of tube to watch
.useTube(tube)return name of tube used by clienttubename of tube to use
.getJob()return ajob. Get available for reserve job from tubes watched by client.jobis object
{
id: jobid, // Job id
data: payload // Job data
}.buryJob(job)takes wholejobobject (or just something that have .id property) and bury it.releaseJob(job)releases ajob.checkJob()returntrueif there is avalable for release job in tube used by client. Return false if not. Dont reserve jobs, just check..putJob(data, priority, delay)put job to a tube used by a clientdatapayload for future job.prioritysmaller integer means higher priority. Default is0.delaydelay in seconds. Default is0.
deleteJob(job)delete jobjobjob object
.stats()Return stats of the server.statsTube(name)Return stats of tubenamename of tube
.listTubes()List tubes. Yes.
License
MIT