co-job
Run jobs in limited runners. Jobs can dynamicly be pushed in current runner
Note: if job contains error it will break runner processing. So you should process error with try/catch
in your job
Quick start
const co = const coJob =
Dependency
API
constructor(limit: Number, options: Object): Runner
Return a job runner with limited cocurrency runners.
options:
- retainResult: <boolean> retain the result when run
runner.end()
. Or it would be an empty array. Default: true
Runner.push(job: yieldable): void
push yieldable job into runner include Promise
, generator
and normal function
Runner.end(): Promise
return a Promise with final result for all jobs
Runner Event: 'done'
Emit when one of the yieldable job finished.
- job result: <any>
- job sequence: <int> present as the job id as the sequence the job pushed.
Runner Event: 'drain'
Emit when one of the cocurrency runner finished its job squence.