forever-task
v0.1.2
Published
- 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
Downloads
14
Readme
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)