pub struct CrawlerBuilder<K: CrawlerKind> { /* private fields */ }Expand description
Builds a Crawler around a crawler kind.
Implementations§
Source§impl<K: CrawlerKind> CrawlerBuilder<K>
impl<K: CrawlerKind> CrawlerBuilder<K>
Sourcepub fn request_handler<H: RequestHandler<K::Context>>(self, handler: H) -> Self
pub fn request_handler<H: RequestHandler<K::Context>>(self, handler: H) -> Self
Sets the request handler.
Sourcepub fn failed_request_handler<H: FailedRequestHandler>(self, handler: H) -> Self
pub fn failed_request_handler<H: FailedRequestHandler>(self, handler: H) -> Self
Sets the permanent-failure handler.
Sourcepub fn max_concurrency(self, count: usize) -> Self
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.
Sourcepub fn min_concurrency(self, count: usize) -> Self
pub fn min_concurrency(self, count: usize) -> Self
Sets the minimum dynamic concurrency.
Sourcepub fn desired_concurrency(self, count: usize) -> Self
pub fn desired_concurrency(self, count: usize) -> Self
Sets the initial desired dynamic concurrency.
Sourcepub fn autoscale_mode(self, mode: AutoscaleMode) -> Self
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.
Sourcepub fn max_tasks_per_minute(self, count: u32) -> Self
pub fn max_tasks_per_minute(self, count: u32) -> Self
Sets the maximum number of task starts permitted per minute.
Sourcepub fn same_domain_delay(self, delay: Duration) -> Self
pub fn same_domain_delay(self, delay: Duration) -> Self
Sets the minimum delay between requests to the same domain.
Sourcepub fn autoscaled_pool_options(self, options: AutoscaledPoolOptions) -> Self
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.
Sourcepub fn max_request_retries(self, count: u32) -> Self
pub fn max_request_retries(self, count: u32) -> Self
Sets the maximum number of ordinary request retries.
Sourcepub fn max_session_rotations(self, count: u32) -> Self
pub fn max_session_rotations(self, count: u32) -> Self
Sets the maximum number of session rotations.
Sourcepub fn request_handler_timeout(self, timeout: Duration) -> Self
pub fn request_handler_timeout(self, timeout: Duration) -> Self
Sets the request-handler timeout.
Sourcepub fn internal_operation_timeout(self, timeout: Duration) -> Self
pub fn internal_operation_timeout(self, timeout: Duration) -> Self
Sets the internal storage-operation timeout.
Sourcepub fn configuration(self, configuration: Configuration) -> Self
pub fn configuration(self, configuration: Configuration) -> Self
Sets the resolved crawler configuration.
Sourcepub fn storage_client(self, storage: Arc<dyn StorageClient>) -> Self
pub fn storage_client(self, storage: Arc<dyn StorageClient>) -> Self
Overrides the configuration’s storage client.
Sourcepub fn request_queue(self, queue: Arc<dyn RequestQueue>) -> Self
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.
Sourcepub fn results_capacity(self, capacity: usize) -> Self
pub fn results_capacity(self, capacity: usize) -> Self
Sets the terminal-result broadcast capacity.
Sourcepub fn retry_strategy<S: RetryStrategy>(self, strategy: S) -> Self
pub fn retry_strategy<S: RetryStrategy>(self, strategy: S) -> Self
Installs an attempt-level retry strategy.
Sourcepub fn crawl_policy(self, policy: CrawlPolicy) -> Self
pub fn crawl_policy(self, policy: CrawlPolicy) -> Self
Sets the long-lived link admission and crawl-limit policy.
Sourcepub async fn build(self) -> Result<Crawler<K>, CrawlerBuildError>
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.