Skip to main content

krabka_client_streams/membership/
types.rs

1//! Public value types surfaced by [`StreamsMembership`](super::StreamsMembership).
2
3/// A concrete topic-partition a task consumes.
4///
5/// The order is by topic first and then by partition, so a barrier cut can hold
6/// its missing partitions in a sorted set.
7#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
8pub struct TopicPartition {
9    pub topic: String,
10    pub partition: i32,
11}
12
13/// One assigned task and the source topic-partitions it processes.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct TaskAssignment {
16    pub subtopology_id: String,
17    pub partitions: Vec<i32>,
18    pub source_topic_partitions: Vec<TopicPartition>,
19}
20
21/// The active tasks, the standby tasks, and the warmup tasks assigned to this
22/// member.
23#[derive(Debug, Clone, Default, PartialEq, Eq)]
24pub struct StreamsAssignment {
25    pub active: Vec<TaskAssignment>,
26    pub standby: Vec<TaskAssignment>,
27    pub warmup: Vec<TaskAssignment>,
28}
29
30/// A tracker to share task restored and end offsets with the coordinator loop.
31#[derive(Debug, Clone, Default)]
32pub struct TaskOffsetTracker {
33    pub task_offsets: std::collections::HashMap<(String, i32), i64>,
34    pub task_end_offsets: std::collections::HashMap<(String, i32), i64>,
35}
36
37/// A non-ready status that the coordinator reports, using the KIP-1071 status
38/// codes.
39#[derive(Debug, Clone, PartialEq, Eq)]
40pub enum StreamsStatus {
41    StaleTopology(String),
42    MissingSourceTopics(String),
43    IncorrectlyPartitionedTopics(String),
44    MissingInternalTopics(String),
45    ShutdownApplication,
46    AssignmentDelayed(String),
47    Unknown(i8, String),
48}
49
50/// An event emitted by the membership heartbeat loop.
51#[derive(Debug, Clone, PartialEq, Eq)]
52pub enum StreamsEvent {
53    /// A new assignment was adopted.
54    Assigned(StreamsAssignment),
55    /// The group is not ready, for example because a source topic or an
56    /// internal topic is missing.
57    NotReady(Vec<StreamsStatus>),
58    /// The broker fenced this member and the client rejoined automatically. A
59    /// fresh assignment follows.
60    Fenced,
61}