Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config { pub part_size_bytes: PartSizeBytes, pub max_concurrency: MaxConcurrency, pub min_parts_for_concurrent_download: MinPartsForConcurrentDownload, pub min_bytes_for_concurrent_download: MinBytesForConcurrentDownload, pub sequential_download_mode: SequentialDownloadMode, pub ensure_active_pull: EnsureActivePull, pub buffer_size: BufferSize, pub max_buffers_full_delay_ms: MaxBuffersFullDelayMs, pub log_download_messages_as_debug: LogDownloadMessagesAsDebug, pub retries: Option<RetryConfig>, }
Expand description

A configuration for Condow.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§part_size_bytes: PartSizeBytes

Size in bytes of the parts the download is split into

Default is 4 Mebi.

§max_concurrency: MaxConcurrency

The maximum concurrency for a single download.

Actual concurrency can be lower if less parts than max_concurrency are to be downloaded

§min_parts_for_concurrent_download: MinPartsForConcurrentDownload

The minimum number of parts a download must consist of for the parts to be downloaded concurrently. Depending on the part sizes it might be more efficient to set a number higer than 2. Downloading concurrently has an overhead. This setting plays together with MinBytesForConcurrentDownload. Setting this value to 0 or 1 makes no sense and has no effect. The default is 2.

§min_bytes_for_concurrent_download: MinBytesForConcurrentDownload

The minimum number of bytes a download must consist of for the parts to be downloaded concurrently. Downloading concurrently has an overhead so it can make sens to set this value greater that PART_SIZE_BYTES.

This setting plays together with MinPartsForConcurrentDownload.

The default is 0.

§sequential_download_mode: SequentialDownloadMode

Define how parts for a sequential download should be treated.

A sequential download can not only be triggered by just one part being requested but also by the MinBytesForConcurrentDownload and MinPartsForConcurrentDownload configuration values.

The default is [SequentialDownloadMode::SingleDownload].

§ensure_active_pull: EnsureActivePull

Make sure that the network stream is always actively pulled into an intermediate buffer.

This is not always the case since some low concurrency downloads require the strem to be actively pulled. This also allows for detection of panics.

The default is false which means this feature is turned off.

§buffer_size: BufferSize

Size of the buffer for each download task.

If set to 0 (not advised) there will be now buffer at all. This should be configured so that none of the tasks runs ever empty

Default is 2

§max_buffers_full_delay_ms: MaxBuffersFullDelayMs

If all buffers of all download tasks are full, this is the maximum time to pause until the next attempt.

Default is 10ms

§log_download_messages_as_debug: LogDownloadMessagesAsDebug

If set to true download related messages are logged at DEBUG level. Otherwise at INFO level.

The affectd messages are:

  • Download started
  • Download completed
  • Download failed
§retries: Option<RetryConfig>

Configures retries if there.

Otherwise there won’t be any retry attempts made

Retries are turned on by default

Implementations§

Source§

impl Config

Source

pub fn from_env() -> Result<Option<Config>, Error>

Tries to initialize all fields from environment variables prefixed with “CONDOW_” If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Source

pub fn from_env_type_names() -> Result<Option<Config>, Error>

Tries to initialize all fields from environment variables without any prefix If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Source

pub fn from_env_prefixed<T>(prefix: T) -> Result<Option<Config>, Error>
where T: AsRef<str>,

Tries to initialize all fields from environment variables prefixed with “[prefix]_”

The underscore is omitted if prefix is empty If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Source

pub fn part_size_bytes<T>(self, part_size_bytes: T) -> Config
where T: Into<PartSizeBytes>,

Set the size of the parts the download is split into in bytes

Source

pub fn max_concurrency<T>(self, max_concurrency: T) -> Config
where T: Into<MaxConcurrency>,

Set the maximum concurrency of a download

Source

pub fn min_parts_for_concurrent_download<T>( self, min_parts_for_concurrent_download: T, ) -> Config

The minimum number of parts a download must consist of for the parts to be downloaded concurrently. Depending on the part sizes it might be more efficient to set a number higer than 2. Downloading concurrently has an overhead. This setting plays together with MinBytesForConcurrentDownload. Setting this value to 0 or 1 makes no sense and has no effect. The default is 2.

Source

pub fn min_bytes_for_concurrent_download<T>( self, min_bytes_for_concurrent_download: T, ) -> Config

The minimum number of bytes a download must consist of for the parts to be downloaded concurrently. Downloading concurrently has an overhead so it can make sens to set this value greater that PART_SIZE_BYTES.

This setting plays together with MinPartsForConcurrentDownload.

The default is 0.

Source

pub fn sequential_download_mode<T>(self, sequential_download_mode: T) -> Config

The minimum number of bytes a download must consist of for the parts to be downloaded concurrently. Downloading concurrently has an overhead so it can make sens to set this value greater that PART_SIZE_BYTES.

This setting plays together with MinPartsForConcurrentDownload.

The default is 0.

Source

pub fn ensure_active_pull<T>(self, ensure_active_pull: T) -> Config

Make sure that the network stream is always actively pulled into an intermediate buffer.

This is not always the case since some low concurrency downloads require the strem to be actively pulled. This also allows for detection of panics.

The default is false which means this feature is turned off.

Source

pub fn buffer_size<T>(self, buffer_size: T) -> Config
where T: Into<BufferSize>,

Set the size of the buffer for each download task.

Source

pub fn max_buffers_full_delay_ms<T>( self, max_buffers_full_delay_ms: T, ) -> Config

Set the maximum delay in case all task buffers are full before a retry to enqueue the next downlod part is made.

Source

pub fn log_download_messages_as_debug<T>( self, log_download_messages_as_debug: T, ) -> Config

If set to true download related messages are logged at DEBUG level. Otherwise at INFO level.

The affectd messages are:

  • download started
  • download completed
  • download failed
Source

pub fn retries(self, config: RetryConfig) -> Config

Enables retries with the given configuration

Source

pub fn configure_retries<F>(self, f: F) -> Config

Configure retries

Uses the currently configured RetryConfig or the default of RetryConfig if none is configured

Source

pub fn configure_retries_from_default<F>(self, f: F) -> Config

Configure retries starting with the default

Source

pub fn disable_retries(self) -> Config

Disables retries

Retries are enabled by default.

Source

pub fn validated(self) -> Result<Config, Error>

Validate this Config

Source

pub fn validate(&self) -> Result<(), Error>

Validate this Config

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> 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 = 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