Skip to main content

StreamsGroupSession

Struct StreamsGroupSession 

Source
pub struct StreamsGroupSession { /* private fields */ }
Expand description

An active Kafka Streams group membership session.

A session starts by sending API 88 with a client-generated member ID, member epoch zero, and the configured topology. Subsequent calls send the current member epoch and only transmit changed membership data according to Kafka’s nullable protocol fields. Call Self::close to leave gracefully.

Implementations§

Source§

impl StreamsGroupSession

Source

pub async fn join(config: StreamsGroupConfig) -> Result<Self>

Joins the configured Kafka Streams group.

Source

pub fn group_id(&self) -> &str

Returns the Kafka Streams group ID.

Source

pub fn member_id(&self) -> &str

Returns the client-generated member ID used for this Streams session.

Source

pub fn member_epoch(&self) -> i32

Returns the current member epoch.

Source

pub fn heartbeat_interval(&self) -> Duration

Returns the broker-requested heartbeat interval.

Source

pub fn assignment(&self) -> &StreamsGroupSessionAssignment

Returns the latest successful assignment snapshot.

A None collection means that Kafka omitted the nullable field in its response; it is distinct from Some(Vec::new()), which is an explicit empty assignment.

Source

pub fn set_task_state( &mut self, active_tasks: Vec<StreamsGroupHeartbeatTask>, standby_tasks: Vec<StreamsGroupHeartbeatTask>, warmup_tasks: Vec<StreamsGroupHeartbeatTask>, task_offsets: Vec<StreamsGroupHeartbeatTaskOffset>, task_end_offsets: Vec<StreamsGroupHeartbeatTaskOffset>, )

Replaces the task state and changelog offsets reported on the next heartbeat.

Empty vectors are meaningful and are sent as empty compact arrays. The values remain pending until a heartbeat succeeds, so a reconnect does not silently lose a task-state update.

Source

pub fn set_task_state_with_optional_offsets( &mut self, active_tasks: Vec<StreamsGroupHeartbeatTask>, standby_tasks: Vec<StreamsGroupHeartbeatTask>, warmup_tasks: Vec<StreamsGroupHeartbeatTask>, task_offsets: Option<Vec<StreamsGroupHeartbeatTaskOffset>>, task_end_offsets: Option<Vec<StreamsGroupHeartbeatTaskOffset>>, )

Replaces task state while optionally omitting changelog offsets.

Kafka 4.3 currently rejects non-null task-offset fields for some Streams group configurations. Passing None preserves the protocol’s nullable field semantics and lets the broker request offsets when supported.

Source

pub fn is_closed(&self) -> bool

Returns whether the session has left the group.

Source

pub async fn heartbeat(&mut self) -> Result<StreamsGroupHeartbeatResponseV0>

Sends one Streams heartbeat and returns the broker’s assignment state.

Coordinator transport failures and member/coordinator epoch errors are recovered within the configured retry budget. A rejoin resends the initial topology and updates the session’s member identity.

Source

pub async fn close(&mut self) -> Result<()>

Leaves the Streams group using member epoch -1.

Source

pub fn spawn_heartbeat_task(self) -> StreamsGroupSessionHandle

Moves this session into a background heartbeat task.

The session must already be joined. The task sends heartbeats using the interval most recently returned by Kafka, publishes every successful assignment through StreamsGroupSessionHandle::subscribe_assignment, and preserves the existing bounded retry and rejoin behavior.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more