Skip to main content

RequestQueueClient

Struct RequestQueueClient 

Source
pub struct RequestQueueClient { /* private fields */ }
Expand description

Client for a specific request queue.

Implementations§

Source§

impl RequestQueueClient

Source

pub fn with_client_key(self, client_key: impl Into<String>) -> Self

Sets the clientKey used to identify this client across requests (for locking).

Source

pub async fn get(&self) -> ApifyClientResult<Option<RequestQueue>>

Fetches the queue metadata, or None if it does not exist.

Source

pub async fn update<T: Serialize>( &self, new_fields: &T, ) -> ApifyClientResult<RequestQueue>

Updates the queue metadata (e.g. name, title).

Source

pub async fn delete(&self) -> ApifyClientResult<()>

Deletes the queue.

Source

pub async fn list_head( &self, limit: Option<i64>, ) -> ApifyClientResult<RequestQueueHead>

Lists requests from the head of the queue (without locking them).

Source

pub async fn add_request( &self, request: &RequestQueueRequest, forefront: bool, ) -> ApifyClientResult<RequestQueueOperationInfo>

Adds a single request to the queue. If forefront is true, adds it to the front.

Source

pub async fn get_request( &self, id: &str, ) -> ApifyClientResult<Option<RequestQueueRequest>>

Gets a request by ID, or None if it does not exist.

Source

pub async fn update_request( &self, request: &RequestQueueRequest, forefront: bool, ) -> ApifyClientResult<RequestQueueOperationInfo>

Updates a request (which must include its id).

Source

pub async fn delete_request(&self, id: &str) -> ApifyClientResult<()>

Deletes a request by ID.

Source

pub async fn list_and_lock_head( &self, lock_secs: i64, limit: Option<i64>, ) -> ApifyClientResult<LockedRequestQueueHead>

Lists and locks requests from the head of the queue for lock_secs seconds.

Source

pub async fn batch_add_requests( &self, requests: &[RequestQueueRequest], options: BatchAddRequestsOptions, ) -> ApifyClientResult<BatchRequestsOperationResult>

Adds multiple requests to the queue in a single logical operation.

This is significantly more efficient than calling add_request once per request, especially for large batches: the input is automatically split into chunks that respect both the API’s per-call request-count limit ([MAX_REQUESTS_PER_BATCH_OPERATION]) and its request-body byte-size limit ([MAX_PAYLOAD_SIZE_BYTES]), chunks are sent with up to options.max_parallel API calls in flight at once, and any request an API call reports as unprocessed (typically due to rate limiting) is retried with exponential backoff — matching the reference client’s batchAddRequests. Every request must be identifiable by RequestQueueRequest::unique_key (or, if left unset, by url, the API’s own fallback) so a retried request can be matched back to the original input.

Unlike most methods here, this does not propagate per-chunk API errors: a chunk that fails even after retries has its requests reported in the result’s unprocessed_requests instead, so a batch add of many requests never fails outright over one bad chunk (matching the reference client). It still returns ApifyClientError::InvalidArgument up front, before any request is sent, for an empty requests (matching batch_delete_requests and the reference client, which validates both as non-empty) or if a single request’s JSON is too large to ever fit in a chunk.

Source

pub async fn batch_delete_requests<T: Serialize>( &self, requests: &[T], ) -> ApifyClientResult<BatchRequestsOperationResult>

Deletes multiple requests in a single batch operation.

Unlike batch_add_requests, this does not auto-chunk: the API accepts at most [MAX_REQUESTS_PER_BATCH_OPERATION] requests per call (matching the reference client, which validates rather than chunks), so a larger requests returns ApifyClientError::InvalidArgument before any request is sent.

Source

pub async fn list_requests( &self, options: ListRequestsOptions, ) -> ApifyClientResult<RequestQueueRequestsPage>

Lists requests in the queue.

Supports pagination via limit/exclusive_start_id and the spec’s cursor/filter parameters (see ListRequestsOptions).

Source

pub async fn prolong_request_lock( &self, id: &str, lock_secs: i64, forefront: bool, ) -> ApifyClientResult<RequestLockInfo>

Prolongs the lock on a request for another lock_secs seconds.

If forefront is true, the request moves to the front of the queue when its lock later expires.

Source

pub async fn delete_request_lock( &self, id: &str, forefront: bool, ) -> ApifyClientResult<()>

Releases the lock on a request so other clients can process it.

If forefront is true, the request moves to the front of the queue.

Source

pub fn paginate_requests( &self, page_limit: Option<i64>, ) -> RequestQueueRequestsIterator

Lazily paginates over all requests in the queue, fetching pages on demand.

Returns a RequestQueueRequestsIterator; call its next() to get one request at a time. Pagination uses the API’s opaque nextCursor token: the first page may be anchored with exclusiveStartId, but every subsequent page is fetched with cursor (matching the JS reference). cursor and exclusiveStartId are mutually exclusive.

Source

pub async fn unlock_requests(&self) -> ApifyClientResult<UnlockRequestsResult>

Unlocks all requests currently locked by this client (identified by client_key).

Trait Implementations§

Source§

impl Clone for RequestQueueClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestQueueClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more