Class: WorkerQueue<In, Out>
async.WorkerQueue
Asynchronous worker queue for running jobs with a concurrency limit.
Type parameters
Name |
---|
In |
Out |
Constructors
constructor
• new WorkerQueue<In
, Out
>(concurrency
, process
): WorkerQueue
<In
, Out
>
Create a new worker queue with a concurrency limit and a job handler callback.
Type parameters
Name |
---|
In |
Out |
Parameters
Name | Type | Description |
---|---|---|
concurrency |
number |
Maximum asynchronous jobs to run at once |
process |
JobHandler <In , Out > |
Callback for processing a single job |
Returns
WorkerQueue
<In
, Out
>
Properties
nextJobId
• Private
nextJobId: number
queue
• Private
queue: Queue
<Job
<In
>>
results
• Private
results: Record
<number
, ResolvablePromise
<JobResult
<Out
>>>
Methods
run
▸ run(job
): Promise
<Out
>
Dispatch a job request and wait for the result. The job will be started once a free executor
is found. If the job handler callback throws an error the error will be propagated to the
dispatcher and the run
Promise will reject with the error.
Parameters
Name | Type | Description |
---|---|---|
job |
In |
Job parameters |
Returns
Promise
<Out
>
worker
▸ worker(process
): Promise
<void
>
Parameters
Name | Type |
---|---|
process |
JobHandler <In , Out > |
Returns
Promise
<void
>