use std::sync::Arc;
use std::time::Duration;
pub type UrlRewriter = Arc<dyn Fn(&str) -> String + Send + Sync>;
#[derive(Clone)]
pub struct TransferConfig {
pub concurrency: usize,
pub max_attempts: u32,
pub initial_backoff: Duration,
pub backoff_max: Duration,
pub url_rewriter: Option<UrlRewriter>,
pub batch_size: usize,
pub detect_content_type: bool,
}
impl Default for TransferConfig {
fn default() -> Self {
Self {
concurrency: 8,
max_attempts: 9,
initial_backoff: Duration::from_millis(100),
backoff_max: Duration::from_secs(30),
url_rewriter: None,
batch_size: 100,
detect_content_type: true,
}
}
}
impl std::fmt::Debug for TransferConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TransferConfig")
.field("concurrency", &self.concurrency)
.field("max_attempts", &self.max_attempts)
.field("initial_backoff", &self.initial_backoff)
.field("backoff_max", &self.backoff_max)
.field("url_rewriter", &self.url_rewriter.as_ref().map(|_| "<fn>"))
.field("batch_size", &self.batch_size)
.field("detect_content_type", &self.detect_content_type)
.finish()
}
}