All Projects → delvedor → workq

delvedor / workq

Licence: MIT license
A super tiny work queue

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to workq

spinach
Modern Redis task queue for Python 3
Stars: ✭ 46 (+21.05%)
Mutual labels:  queue, jobs
Swoole Jobs
🚀Dynamic multi process worker queue base on swoole, like gearman but high performance.
Stars: ✭ 574 (+1410.53%)
Mutual labels:  queue, jobs
joobq
JoobQ is a fast, efficient asynchronous reliable job queue and job scheduler library processing. Jobs are submitted to a job queue, where they reside until they are able to be scheduled to run in a computing environment.
Stars: ✭ 26 (-31.58%)
Mutual labels:  queue, jobs
jobs
RoadRunner: Background PHP workers, Queue brokers
Stars: ✭ 59 (+55.26%)
Mutual labels:  queue, jobs
Flask Rq2
A Flask extension for RQ.
Stars: ✭ 176 (+363.16%)
Mutual labels:  queue, jobs
Foundatio.Samples
Foundatio Samples
Stars: ✭ 34 (-10.53%)
Mutual labels:  queue, jobs
Bull
Bull module for Nest framework (node.js) 🐮
Stars: ✭ 356 (+836.84%)
Mutual labels:  queue, jobs
theeye-of-sauron
TheEye Dockers and QuickStart
Stars: ✭ 27 (-28.95%)
Mutual labels:  queue, jobs
Workq
Job server in Go
Stars: ✭ 1,546 (+3968.42%)
Mutual labels:  queue, jobs
Foundatio
Pluggable foundation blocks for building distributed apps.
Stars: ✭ 1,365 (+3492.11%)
Mutual labels:  queue, jobs
dispatcher
Dispatcher is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 60 (+57.89%)
Mutual labels:  queue, jobs
Redis Smq
A simple high-performance Redis message queue for Node.js.
Stars: ✭ 230 (+505.26%)
Mutual labels:  queue, jobs
horizon-exporter
Export Laravel Horizon metrics using this Prometheus exporter.
Stars: ✭ 17 (-55.26%)
Mutual labels:  queue, jobs
Fennel
A task queue library for Python and Redis
Stars: ✭ 24 (-36.84%)
Mutual labels:  queue, jobs
Stevejobs
A simple jobs queue that just works (for Meteor.js)
Stars: ✭ 195 (+413.16%)
Mutual labels:  queue, jobs
qless-php
PHP Bindings for qless
Stars: ✭ 25 (-34.21%)
Mutual labels:  queue, jobs
yii2-queue-monitor
Yii2 Queue Analytics Module
Stars: ✭ 99 (+160.53%)
Mutual labels:  queue
data-structure-project
自己实现集合框架系列整理总结
Stars: ✭ 29 (-23.68%)
Mutual labels:  queue
flask-redis-docker
A minimal template for dockerized flask app with redis task queue
Stars: ✭ 49 (+28.95%)
Mutual labels:  queue
Arduino-Queue.h
Generic C++ circular queue for Arduino embedded projects.
Stars: ✭ 59 (+55.26%)
Mutual labels:  queue

workq

js-standard-style Build Status Coverage Status

A super tiny work queue.

It can handle nested queues, the order of execution is guaranteed.
The top level queue will start automatically once you add at least one job in the queue, the nested queues will start once the done callback has been called; you cannot add more jobs in the current queue after done has been called.

If you need a shared queue between multiple files pass the option { singleton: true } in every file you need it.

Install

npm i workq --save

Usage

const q = require('workq')()

q.add(job)

function job (child, done) {
  // perform some work
  // you can add nested jobs!
  child.add(nestedJob)
  done()
})

function nestedJob (child, done) {
  // perform some work
  done()
})

Async/await and promises are supported as well!

const q = require('workq')()

q.add(job)

// there is no need to call `done`!
async function job (child) {
  // perform some work
  // you can add nested jobs!
  child.add(nestedJob)
})

async function nestedJob (child) {
  // perform some work
})

If you need to know when a queue has finished all its jobs, you can use the drain api.
Note that in the top queue the drain hook can be called multiple times.

const q = require('workq')()

q.drain(done => {
  // the current queue has finished its jobs
  // async await is supported as well
  done()
})

q.add(job)

function job (child, done) {
  // perform some work
  // you can add nested jobs!
  child.add(nestedJob)
  done()
})

function nestedJob (child, done) {
  // perform some work
  done()
})

If you need to pass some parameter to the job, just add them after the function in add:

const q = require('workq')()

q.add(job, 'hello', 42)

function job (child, greeting, num, done) {
  console.log(greeting, num) // 'hello' 42
  done()
})

If needed you can also use the child method to create custom child queues. The child queues will be executed once the current queue has finished its execution.

const q = require('workq')()

const childq = q.child()

q.add(job, 'hello', 42)
childq.add(job, 'hello', 42)

function job (child, greeting, num, done) {
  console.log(greeting, num) // 'hello' 42
  done()
})

License

Licensed under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].