Socket
Book a DemoInstallSign in
Socket

co-jobs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-jobs

job manager with concurrency and prioritization

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
3
-40%
Maintainers
1
Weekly downloads
 
Created
Source

Co Jobs

A job handler with concurrency and prioritization.

var jobs = require('jobs')()
jobs.concurrency = 5

co(function* () {
  jobs.push('task1id', task1)
  jobs.push('task2id', task2)

  var result1 = yield jobs.await('task1id')
})

API

var jobs = Jobs([options])

Create a new jobs instance. Options:

  • concurrency: 1

jobs.concurrency=

Set the concurrency of the jobs.

var length = jobs.push([id], fn, [priority])

Push a job to be run.

  • fn - currently jobs must be a thunk.
  • id - a unique job id as a string. Defaults to a random string.
  • priority: 0 - a priority as a number.

var result = yield jobs.await(event)

Await the result of an event. All job ids are emitted as events. There are additionally these events:

  • drain - when there are no more jobs to run

jobs.prioritize(id, priority)

If a job by id exists, sets its priority to priority.

FAQs

Package last updated on 06 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts