Promise wraper for fivebeans client so you can use promises instead of callbacks and await them
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()
-
constructor(debug, default_ttl)
Create new instance of beanstalk-promises client.- If
debug
is true (or if it just exist) it will print debug messages. default_ttl
is a parameter that sets how long job could be reserved.
- If
-
.connect(host, port, reconnect)
reconnect
is a number in miliseconds, client will reconnect to beanstalk after it if something happens. Set0
to disable.
-
.quit()
Disconnects the client, no reconnect. -
.watchTube(tube)
return number of watched tubestube
name of tube to watch
-
.useTube(tube)
return name of tube used used by clienttube
name of tube to use
-
.getJob()
return ajob
. Get available for reserve job from tubes watched by client. -
job
is object
{
id: jobid, // Job id
data: payload // Job data
}
-
.buryJob(job)
takes wholejob
object (or just something that have .id property) and bury it -
.releaseJob(job)
releases ajob
-
.checkJob()
returntrue
if 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 clientdata
payload for future job.priority
smaller integer means higher priority. Default is0
.delay
delay in seconds. Default is0
.
-
deleteJob(job)
delete jobjob
job object
-
.stats()
Return stats of the server -
.statsTube(name)
Return stats of tubename
name of tube
-
.listTubes()
List tubes. Yes.
MIT