Skip to main content

crabka_client_streams/membership/
types.rs

1//! Public value types surfaced by [`StreamsMembership`](super::StreamsMembership).
2
3/// A concrete topic-partition a task consumes.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct TopicPartition {
6    pub topic: String,
7    pub partition: i32,
8}
9
10/// One assigned task and the source topic-partitions it processes.
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct TaskAssignment {
13    pub subtopology_id: String,
14    pub partitions: Vec<i32>,
15    pub source_topic_partitions: Vec<TopicPartition>,
16}
17
18/// The active/standby/warmup tasks assigned to this member.
19#[derive(Debug, Clone, Default, PartialEq, Eq)]
20pub struct StreamsAssignment {
21    pub active: Vec<TaskAssignment>,
22    pub standby: Vec<TaskAssignment>,
23    pub warmup: Vec<TaskAssignment>,
24}
25
26/// A tracker to share task restored and end offsets with the coordinator loop.
27#[derive(Debug, Clone, Default)]
28pub struct TaskOffsetTracker {
29    pub task_offsets: std::collections::HashMap<(String, i32), i64>,
30    pub task_end_offsets: std::collections::HashMap<(String, i32), i64>,
31}
32
33/// A non-ready status reported by the coordinator (KIP-1071 status codes).
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub enum StreamsStatus {
36    StaleTopology(String),
37    MissingSourceTopics(String),
38    IncorrectlyPartitionedTopics(String),
39    MissingInternalTopics(String),
40    ShutdownApplication,
41    AssignmentDelayed(String),
42    Unknown(i8, String),
43}
44
45/// An event emitted by the membership heartbeat loop.
46#[derive(Debug, Clone, PartialEq, Eq)]
47pub enum StreamsEvent {
48    /// A new assignment was adopted.
49    Assigned(StreamsAssignment),
50    /// The group is not ready (e.g. missing source/internal topics).
51    NotReady(Vec<StreamsStatus>),
52    /// We were fenced and auto-rejoined; a fresh assignment will follow.
53    Fenced,
54}