pub struct ConfigBuilder { /* private fields */ }Expand description
Builder for creating Config instances with custom settings.
ConfigBuilder provides a fluent interface for constructing Config objects
with specific settings. All methods return self to enable method chaining.
Call build() to create the final Config instance.
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;
let config = ConfigBuilder::new()
.host("queue.example.com")
.port(8080)
.timeout_ms(5000) // 5 second timeout
.max_retries(2) // Only retry twice
.retry_delay_ms(250) // 250ms base delay
.build();
assert_eq!(config.host, "queue.example.com");
assert_eq!(config.port, 8080);
assert_eq!(config.timeout, Duration::from_millis(5000));Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ConfigBuilder with default settings.
Equivalent to Config::default() but allows method chaining.
§Examples
use tlq_client::ConfigBuilder;
let builder = ConfigBuilder::new();
let config = builder.build();Sourcepub fn timeout_ms(self, ms: u64) -> Self
pub fn timeout_ms(self, ms: u64) -> Self
Sets the request timeout in milliseconds.
Convenience method equivalent to timeout(Duration::from_millis(ms)).
§Arguments
ms- Timeout in milliseconds
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;
let config = ConfigBuilder::new()
.timeout_ms(5000) // 5 seconds
.build();
assert_eq!(config.timeout, Duration::from_millis(5000));Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Sets the maximum number of retry attempts.
When a retryable error occurs, the client will retry the operation up to this many times before giving up.
§Arguments
retries- Maximum retry attempts (0 disables retries)
§Examples
use tlq_client::ConfigBuilder;
let config = ConfigBuilder::new()
.max_retries(5)
.build();
assert_eq!(config.max_retries, 5);Sourcepub fn retry_delay(self, delay: Duration) -> Self
pub fn retry_delay(self, delay: Duration) -> Self
Sets the base retry delay duration.
The actual delay between retries uses exponential backoff: delay = base_delay × 2^attempt_number
§Arguments
delay- Base delay for exponential backoff
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;
let config = ConfigBuilder::new()
.retry_delay(Duration::from_millis(500))
.build();
assert_eq!(config.retry_delay, Duration::from_millis(500));Sourcepub fn retry_delay_ms(self, ms: u64) -> Self
pub fn retry_delay_ms(self, ms: u64) -> Self
Sets the base retry delay in milliseconds.
Convenience method equivalent to retry_delay(Duration::from_millis(ms)).
§Arguments
ms- Base delay in milliseconds
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;
let config = ConfigBuilder::new()
.retry_delay_ms(200) // 200ms base delay
.build();
assert_eq!(config.retry_delay, Duration::from_millis(200));