npm.io
0.1.2 • Published 8 years ago

forever-task

Licence
MIT
Version
0.1.2
Deps
6
Size
78 kB
Vulns
2
Weekly
0

Forever Task

  • Forever task is a task which only stops when receiving stop signal. While running, it emits some data.
  • Forever tasks include crawling, micro service, etc
  • Allow distributed workers

Installation

$ npm install forever-task

Usage

1. Worker
const { Forever } = require('forever-task')
const forever = new Forever()
forever.process({
  MyId: {
    resolver(_, { send }) {
      send({ ping: true })
    }
  }
})
2. start/stop Worker
const jobId = forever.start('MyId')
// stop
forever.stop(jobId)
3. ubscribe/unsubscribe to data
const subId = forever.subscribe('MyId')
// unsubscribe
forever.unsubscribe(subId)