use std::time::Duration;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PipelineOptions {
pub timeout: Option<Duration>,
pub retry_server_error: bool,
pub retry_connection_error: bool,
}
impl PipelineOptions {
pub fn new() -> Self {
PipelineOptions::default()
}
#[must_use]
pub fn with_timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
#[must_use]
pub fn with_retry_server_error(mut self, retry: bool) -> Self {
self.retry_server_error = retry;
self
}
#[must_use]
pub fn with_retry_connection_error(mut self, retry: bool) -> Self {
self.retry_connection_error = retry;
self
}
pub(crate) fn timeout_millis(&self) -> Option<u32> {
self.timeout
.map(|d| u32::try_from(d.as_millis()).unwrap_or(u32::MAX))
}
}