GithubHelp home page GithubHelp logo

jansenignacio / beanstalk-promises Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kirill-dev-pro/beanstalk-promises

0.0 0.0 0.0 32 KB

Promise wraper for fivebeans client so you can use promises instead of callbacks and await them

License: MIT License

JavaScript 100.00%

beanstalk-promises's Introduction

beanstalk-promises JavaScript Style Guide Test Coverage Issue Count

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 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.
  • .connect(host, port, reconnect)

    • reconnect is a number in miliseconds, client will reconnect to beanstalk after it if something happens. Set 0 to disable.
  • .quit() Disconnects the client, no reconnect.

  • .watchTube(tube) return number of watched tubes

    • tube name of tube to watch
  • .useTube(tube) return name of tube used used by client

    • tube name of tube to use
  • .getJob() return a job. Get available for reserve job from tubes watched by client.

  • job is object

{
  id: jobid,    // Job id 
  data: payload // Job data
}
  • .buryJob(job) takes whole job object (or just something that have .id property) and bury it

  • .releaseJob(job) releases a job

  • .checkJob() return true 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 client

    • data payload for future job.
    • priority smaller integer means higher priority. Default is 0.
    • delay delay in seconds. Default is 0.
  • deleteJob(job) delete job

    • job job object
  • .stats() Return stats of the server

  • .statsTube(name) Return stats of tube

    • name name of tube
  • .listTubes() List tubes. Yes.

License

MIT

beanstalk-promises's People

Contributors

jansenignacio avatar kirill-dev-pro avatar mattsoftware avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.