#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.part_size_bytes: PartSizeBytesSize in bytes of the parts the download is split into
Default is 4 Mebi.
max_concurrency: MaxConcurrencyThe 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: MinPartsForConcurrentDownloadThe 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: MinBytesForConcurrentDownloadThe 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: SequentialDownloadModeDefine 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: EnsureActivePullMake 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: BufferSizeSize 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: MaxBuffersFullDelayMsIf 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: LogDownloadMessagesAsDebugIf set to true download related messages are logged at DEBUG level. Otherwise at INFO level.
The affectd messages are:
Download startedDownload completedDownload 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
impl Config
Sourcepub fn from_env() -> Result<Option<Config>, Error>
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.
Sourcepub fn from_env_type_names() -> Result<Option<Config>, Error>
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.
Sourcepub fn from_env_prefixed<T>(prefix: T) -> Result<Option<Config>, Error>
pub fn from_env_prefixed<T>(prefix: T) -> Result<Option<Config>, Error>
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.
Sourcepub fn part_size_bytes<T>(self, part_size_bytes: T) -> Configwhere
T: Into<PartSizeBytes>,
pub fn part_size_bytes<T>(self, part_size_bytes: T) -> Configwhere
T: Into<PartSizeBytes>,
Set the size of the parts the download is split into in bytes
Sourcepub fn max_concurrency<T>(self, max_concurrency: T) -> Configwhere
T: Into<MaxConcurrency>,
pub fn max_concurrency<T>(self, max_concurrency: T) -> Configwhere
T: Into<MaxConcurrency>,
Set the maximum concurrency of a download
Sourcepub fn min_parts_for_concurrent_download<T>(
self,
min_parts_for_concurrent_download: T,
) -> Configwhere
T: Into<MinPartsForConcurrentDownload>,
pub fn min_parts_for_concurrent_download<T>(
self,
min_parts_for_concurrent_download: T,
) -> Configwhere
T: Into<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.
Sourcepub fn min_bytes_for_concurrent_download<T>(
self,
min_bytes_for_concurrent_download: T,
) -> Configwhere
T: Into<MinBytesForConcurrentDownload>,
pub fn min_bytes_for_concurrent_download<T>(
self,
min_bytes_for_concurrent_download: T,
) -> Configwhere
T: Into<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.
Sourcepub fn sequential_download_mode<T>(self, sequential_download_mode: T) -> Configwhere
T: Into<SequentialDownloadMode>,
pub fn sequential_download_mode<T>(self, sequential_download_mode: T) -> Configwhere
T: Into<SequentialDownloadMode>,
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.
Sourcepub fn ensure_active_pull<T>(self, ensure_active_pull: T) -> Configwhere
T: Into<EnsureActivePull>,
pub fn ensure_active_pull<T>(self, ensure_active_pull: T) -> Configwhere
T: Into<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.
Sourcepub fn buffer_size<T>(self, buffer_size: T) -> Configwhere
T: Into<BufferSize>,
pub fn buffer_size<T>(self, buffer_size: T) -> Configwhere
T: Into<BufferSize>,
Set the size of the buffer for each download task.
Sourcepub fn max_buffers_full_delay_ms<T>(
self,
max_buffers_full_delay_ms: T,
) -> Configwhere
T: Into<MaxBuffersFullDelayMs>,
pub fn max_buffers_full_delay_ms<T>(
self,
max_buffers_full_delay_ms: T,
) -> Configwhere
T: Into<MaxBuffersFullDelayMs>,
Set the maximum delay in case all task buffers are full before a retry to enqueue the next downlod part is made.
Sourcepub fn log_download_messages_as_debug<T>(
self,
log_download_messages_as_debug: T,
) -> Configwhere
T: Into<LogDownloadMessagesAsDebug>,
pub fn log_download_messages_as_debug<T>(
self,
log_download_messages_as_debug: T,
) -> Configwhere
T: Into<LogDownloadMessagesAsDebug>,
If set to true download related messages are logged at DEBUG level. Otherwise at INFO level.
The affectd messages are:
download starteddownload completeddownload failed
Sourcepub fn retries(self, config: RetryConfig) -> Config
pub fn retries(self, config: RetryConfig) -> Config
Enables retries with the given configuration
Sourcepub fn configure_retries<F>(self, f: F) -> Config
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
Sourcepub fn configure_retries_from_default<F>(self, f: F) -> Config
pub fn configure_retries_from_default<F>(self, f: F) -> Config
Configure retries starting with the default
Sourcepub fn disable_retries(self) -> Config
pub fn disable_retries(self) -> Config
Disables retries
Retries are enabled by default.