IRequestManager
Hierarchy
- IRequestLoader
- IRequestManager
Implemented by
Index
Methods
inherited[asyncIterator]
Can be used to iterate over the loader instance in a
for await .. ofloop. Provides an alternative for the repeated use offetchNextRequest.Returns AsyncGenerator<CrawleeRequest<Dictionary>, any, any>
addRequest
Parameters
requestLike: Source
optionaloptions: RequestQueueOperationOptions
Returns Promise<RequestQueueOperationInfo>
addRequestsBatched
Parameters
requests: RequestsLike
optionaloptions: AddRequestsBatchedOptions
Returns Promise<AddRequestsBatchedResult>
inheritedfetchNextRequest
Gets the next Request to process, or
nullif there are no more pending requests.The returned request is marked as in progress and remains so until it is passed to IRequestLoader.markRequestAsHandled. The caller is responsible for eventually marking every fetched request as handled; otherwise the loader never considers itself finished and the request may be re-served after a restart. See the request lifecycle contract on IRequestLoader.
Returns Promise<null | CrawleeRequest<T>>
inheritedgetHandledCount
Returns the number of requests in the loader that have been handled.
Returns Promise<number>
inheritedgetPendingCount
Returns an approximation of the number of pending requests in the loader.
Returns Promise<number>
inheritedgetTotalCount
Returns an approximation of the total number of requests in the loader (i.e. pending + handled).
Returns Promise<number>
inheritedisEmpty
Resolves to
trueif the next call to IRequestLoader.fetchNextRequest function would returnnull, otherwise it resolves tofalse. Note that even if the loader is empty, there might be some pending requests currently being processed.This is a statement about what the next fetch would return, not about how much work is left, so it may report
truewhile IRequestLoader.getPendingCount is non-zero - a loader that withholds requests for a while (as ThrottlingRequestManager does for a rate-limited domain) is empty for as long as it will not hand anything over. UseisFinished()to ask whether the work is done.Returns Promise<boolean>
inheritedisFinished
Returns
trueif all requests were already handled and there are no more left.Returns Promise<boolean>
inheritedmarkRequestAsHandled
Marks a request previously returned by IRequestLoader.fetchNextRequest as handled, removing it from the set of in-progress requests.
Call this once you are done with the request — whether processing succeeded or was abandoned after exhausting retries. Because a loader cannot take a request back, marking it handled is the only way to signal completion; failing to do so prevents IRequestLoader.isFinished from ever resolving to
trueand skews the handled and pending counts. See the request lifecycle contract on IRequestLoader.Parameters
request: CrawleeRequest<Dictionary>
Returns Promise<null | void | RequestQueueOperationInfo>
optionalinheritedpersistState
Persists the current state of the loader into the default KeyValueStore.
Not all loaders support persistence; implementations that do not should leave this
undefined.Returns Promise<void>
optionalpurge
Remove all requests from the queue but keep the queue itself, resetting it so it can be reused (e.g. across multiple
crawler.run()calls).Implementations that do not support purging may leave this
undefined.Returns Promise<void>
reclaimRequest
Reclaims request to the provider if its processing failed. The request will be returned by some subsequent
fetchNextRequest()call.Parameters
request: CrawleeRequest<Dictionary>
optionaloptions: RequestQueueOperationOptions
Returns Promise<null | RequestQueueOperationInfo>
optionalsetExpectedRequestProcessingTimeSecs
Tells the manager how long a consumer expects to hold a request fetched via
fetchNextRequest()before marking it handled or reclaiming it (typically the request-handler timeout plus padding).Managers backed by a storage backend that reserves requests via locking use this to avoid handing the same request out again while it is still being processed. Implementations that do not need this hint may leave it
undefined.Parameters
secs: number
Returns Promise<void>
optionalinheritedtoTandem
Combines the loader with a request manager to support adding and reclaiming requests.
Parameters
optionalrequestManager: IRequestManager
Request manager to combine the loader with. If not provided, the default RequestQueue is used.
Returns Promise<IRequestManager>
Extends the read-only IRequestLoader interface with the capability to enqueue new requests and reclaim failed ones.