Skip to main content

CrawlerBuilder

Struct CrawlerBuilder 

Source
pub struct CrawlerBuilder<K: CrawlerKind> { /* private fields */ }
Expand description

Builds a Crawler around a crawler kind.

Implementations§

Source§

impl<K: CrawlerKind> CrawlerBuilder<K>

Source

pub fn new(kind: K) -> Self

Creates a builder with engine defaults.

Source

pub fn request_handler<H: RequestHandler<K::Context>>(self, handler: H) -> Self

Sets the request handler.

Source

pub fn failed_request_handler<H: FailedRequestHandler>(self, handler: H) -> Self

Sets the permanent-failure handler.

Source

pub fn max_concurrency(self, count: usize) -> Self

Sets the maximum number of concurrent requests and pins concurrency to that value.

Calling this after Self::autoscale_mode re-pins the crawler to fixed concurrency. Calling Self::autoscale_mode after this method retains count as the dynamic ceiling.

Source

pub fn min_concurrency(self, count: usize) -> Self

Sets the minimum dynamic concurrency.

Source

pub fn desired_concurrency(self, count: usize) -> Self

Sets the initial desired dynamic concurrency.

Source

pub fn autoscale_mode(self, mode: AutoscaleMode) -> Self

Selects dynamic autoscaling.

Calling this after Self::max_concurrency keeps that value as the dynamic ceiling. Calling Self::max_concurrency afterward re-pins concurrency to a fixed value.

Source

pub fn max_tasks_per_minute(self, count: u32) -> Self

Sets the maximum number of task starts permitted per minute.

Source

pub fn same_domain_delay(self, delay: Duration) -> Self

Sets the minimum delay between requests to the same domain.

Source

pub fn autoscaled_pool_options(self, options: AutoscaledPoolOptions) -> Self

Replaces all autoscaled-pool options for advanced use.

The pool’s task_timeout bounds request preparation, execution, and handler work after an attempt starts. Its maybe_run_interval periodically rechecks the queue as a missed-wakeup safety net and must be greater than zero.

Source

pub fn max_request_retries(self, count: u32) -> Self

Sets the maximum number of ordinary request retries.

Source

pub fn max_session_rotations(self, count: u32) -> Self

Sets the maximum number of session rotations.

Source

pub fn request_handler_timeout(self, timeout: Duration) -> Self

Sets the request-handler timeout.

Source

pub fn internal_operation_timeout(self, timeout: Duration) -> Self

Sets the internal storage-operation timeout.

Source

pub fn configuration(self, configuration: Configuration) -> Self

Sets the resolved crawler configuration.

Source

pub fn storage_client(self, storage: Arc<dyn StorageClient>) -> Self

Overrides the configuration’s storage client.

Source

pub fn request_queue(self, queue: Arc<dyn RequestQueue>) -> Self

Overrides the request queue opened from storage.

This hook lets a crate::sitemap::RequestQueueWithSitemap tandem drive the crawler. Callers resuming a pre-populated persistent queue should pair it with crate::config::ConfigurationBuilder::purge_on_start set to false. Storage still supplies the crawler’s key-value store and other storage objects.

Source

pub fn results_capacity(self, capacity: usize) -> Self

Sets the terminal-result broadcast capacity.

Source

pub fn retry_strategy<S: RetryStrategy>(self, strategy: S) -> Self

Installs an attempt-level retry strategy.

Source

pub fn crawl_policy(self, policy: CrawlPolicy) -> Self

Sets the long-lived link admission and crawl-limit policy.

Source

pub async fn build(self) -> Result<Crawler<K>, CrawlerBuildError>

Builds the crawler and opens its configured storage objects.

The default Configuration purges all data managed by the selected storage client before opening the queue and key-value store. Set purge_on_start(false) to retain existing data.

Auto Trait Implementations§

§

impl<K> !RefUnwindSafe for CrawlerBuilder<K>

§

impl<K> !UnwindSafe for CrawlerBuilder<K>

§

impl<K> Freeze for CrawlerBuilder<K>
where K: Freeze,

§

impl<K> Send for CrawlerBuilder<K>

§

impl<K> Sync for CrawlerBuilder<K>

§

impl<K> Unpin for CrawlerBuilder<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for CrawlerBuilder<K>
where K: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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