pub struct StreamConfig {
pub stream_key: String,
pub dead_letter_key: String,
pub consumer_group: String,
pub consumer_name: String,
pub batch_size: usize,
pub block_ms: usize,
pub max_retries: i64,
pub min_idle_ms: u64,
pub reclaim_interval: Duration,
pub group_start_id: String,
pub data_field: String,
}Expand description
Configuration for a Redis Stream consumer.
Fields§
§stream_key: StringRedis stream key to consume from (e.g. “notifications:deposits”).
dead_letter_key: StringRedis stream key for dead-letter messages (e.g. “notifications:deposits:dead_letter”).
consumer_group: StringConsumer group name (e.g. “notification-service”).
consumer_name: StringConsumer name within the group (e.g. “worker-1”).
batch_size: usizeNumber of messages to read per XREADGROUP call.
block_ms: usizeXREADGROUP block timeout in milliseconds.
max_retries: i64Maximum delivery attempts before moving to dead-letter.
min_idle_ms: u64Minimum idle time (ms) before a pending message can be reclaimed via XCLAIM.
reclaim_interval: DurationHow often to run the pending message reclaim loop.
group_start_id: StringStarting message ID for consumer group creation (“$” = new only, “0” = replay all).
data_field: StringField name to extract from stream entries (default: “data”). Some streams use different field names (e.g. “wallet”).
Implementations§
Source§impl StreamConfig
impl StreamConfig
Sourcepub fn new(
stream_key: impl Into<String>,
dead_letter_key: impl Into<String>,
consumer_group: impl Into<String>,
consumer_name: impl Into<String>,
) -> Self
pub fn new( stream_key: impl Into<String>, dead_letter_key: impl Into<String>, consumer_group: impl Into<String>, consumer_name: impl Into<String>, ) -> Self
Create a new config with required fields and sensible defaults.
Defaults: batch_size=10, block_ms=5000, max_retries=5, min_idle_ms=60000, reclaim_interval=30s, group_start_id=“$”.
Sourcepub fn with_min_idle_ms(self, ms: u64) -> Self
pub fn with_min_idle_ms(self, ms: u64) -> Self
Set minimum idle time for pending message reclaim (milliseconds).
Sourcepub fn with_max_retries(self, n: i64) -> Self
pub fn with_max_retries(self, n: i64) -> Self
Set maximum retry count before dead-lettering.
Sourcepub fn with_group_start_id(self, id: impl Into<String>) -> Self
pub fn with_group_start_id(self, id: impl Into<String>) -> Self
Set the group start ID (“$” for new messages only, “0” for replay).
Sourcepub fn with_batch_size(self, n: usize) -> Self
pub fn with_batch_size(self, n: usize) -> Self
Set batch size for XREADGROUP.
Sourcepub fn with_block_ms(self, ms: usize) -> Self
pub fn with_block_ms(self, ms: usize) -> Self
Set block timeout for XREADGROUP (milliseconds).
Sourcepub fn with_reclaim_interval(self, interval: Duration) -> Self
pub fn with_reclaim_interval(self, interval: Duration) -> Self
Set reclaim interval.
Sourcepub fn with_data_field(self, field: impl Into<String>) -> Self
pub fn with_data_field(self, field: impl Into<String>) -> Self
Set the field name to extract from stream entries.
Defaults to “data”. Use this when the producer uses a different field name (e.g. “wallet”).
Trait Implementations§
Source§impl Clone for StreamConfig
impl Clone for StreamConfig
Source§fn clone(&self) -> StreamConfig
fn clone(&self) -> StreamConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more