Create a new IterableQueueMapperSimple, which uses IterableQueueMapper underneath, but
automatically iterates and discards results as they complete.
Function called for every enqueued item. Returns a Promise or value.
IterableQueueMapperSimple options
Private Readonly _donePrivate Readonly _errorsPrivate _isPrivate Readonly _mapperPrivate Readonly _writerAccumulated errors from background mapperss
Reference to the errors array
Note that this property can be periodically checked
during processing and errors can be .pop()'d off of the array
and logged / handled as desired. Errors .pop()'d off of the array
will no longer be available in the array on the next check.
Indicates if all background mappers have finished.
true if .onIdle() has been called and finished all background writes
Private discardAccept a request for sending in the background if a concurrency slot is available. Else, do not return until a concurrency slot is freed up. This provides concurrency background writes with backpressure to prevent the caller from getting too far ahead.
MUST await onIdle for background mapperss to finish
Private workerGenerated using TypeDoc
Accepts queue items via
enqueueand calls themapperon them with specifiedconcurrency, discards the results, and accumulates exceptions in theerrorsproperty. When empty,await enqueue()will return immediately, but whenconcurrencyitems are in progress,await enqueue()will block until a slot is available to accept the item.Remarks
Typical Use Case
concurrency: 1) case, allows 1 item to be flushed async while caller prepares next itemIterableQueueMapper)Error Handling
The mapper should ideally handle all errors internally to enable error handling closest to where they occur. However, if errors do escape the mapper:
errorspropertyerrorspropertyKey Differences from
IterableQueueMapper:maxUnreaddefaults to equalconcurrency(simplifying queue management)Usage
await enqueue()methoderrorsproperty to see if any errors occurred, stop if desiredawait enqueue()method will block until a slot is available, if queue is fullawait onIdle()to ensure all items are processedNote: the name is somewhat of a misnomer as this wraps
IterableQueueMapperbut is not itself anIterable.See