Skip to main content

StreamConfig

Struct StreamConfig 

Source
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: String

Redis stream key to consume from (e.g. “notifications:deposits”).

§dead_letter_key: String

Redis stream key for dead-letter messages (e.g. “notifications:deposits:dead_letter”).

§consumer_group: String

Consumer group name (e.g. “notification-service”).

§consumer_name: String

Consumer name within the group (e.g. “worker-1”).

§batch_size: usize

Number of messages to read per XREADGROUP call.

§block_ms: usize

XREADGROUP block timeout in milliseconds.

§max_retries: i64

Maximum delivery attempts before moving to dead-letter.

§min_idle_ms: u64

Minimum idle time (ms) before a pending message can be reclaimed via XCLAIM.

§reclaim_interval: Duration

How often to run the pending message reclaim loop.

§group_start_id: String

Starting message ID for consumer group creation (“$” = new only, “0” = replay all).

§data_field: String

Field name to extract from stream entries (default: “data”). Some streams use different field names (e.g. “wallet”).

Implementations§

Source§

impl StreamConfig

Source

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=“$”.

Source

pub fn with_min_idle_ms(self, ms: u64) -> Self

Set minimum idle time for pending message reclaim (milliseconds).

Source

pub fn with_max_retries(self, n: i64) -> Self

Set maximum retry count before dead-lettering.

Source

pub fn with_group_start_id(self, id: impl Into<String>) -> Self

Set the group start ID (“$” for new messages only, “0” for replay).

Source

pub fn with_batch_size(self, n: usize) -> Self

Set batch size for XREADGROUP.

Source

pub fn with_block_ms(self, ms: usize) -> Self

Set block timeout for XREADGROUP (milliseconds).

Source

pub fn with_reclaim_interval(self, interval: Duration) -> Self

Set reclaim interval.

Source

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

Source§

fn clone(&self) -> StreamConfig

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 StreamConfig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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.