Skip to main content

kafka_client_engine/consumer/assigned_host/event/
model.rs

1//! Stable scalar events independent of deterministic core representations.
2
3use std::sync::Arc;
4
5/// Exact named assignment and position generation for one failure event.
6#[derive(Debug, Eq, PartialEq)]
7pub struct AssignedConsumerPositionFence {
8    pub(super) topic: Arc<str>,
9    pub(super) partition: i32,
10    pub(super) assignment_epoch: u64,
11    pub(super) position_epoch: u64,
12}
13
14impl AssignedConsumerPositionFence {
15    /// Returns the catalog-owned Kafka topic spelling.
16    pub fn topic(&self) -> &str {
17        &self.topic
18    }
19
20    /// Returns the zero-based Kafka partition.
21    pub const fn partition(&self) -> i32 {
22        self.partition
23    }
24
25    /// Returns the complete assignment generation.
26    pub const fn assignment_epoch(&self) -> u64 {
27        self.assignment_epoch
28    }
29
30    /// Returns the partition-local position generation.
31    pub const fn position_epoch(&self) -> u64 {
32        self.position_epoch
33    }
34}
35
36/// Exact named identity of one failed Fetch execution.
37#[derive(Debug, Eq, PartialEq)]
38pub struct AssignedConsumerFetchFence {
39    pub(super) position: AssignedConsumerPositionFence,
40    pub(super) fetch_revision: u64,
41}
42
43impl AssignedConsumerFetchFence {
44    /// Borrows the exact named position generation.
45    pub const fn position(&self) -> &AssignedConsumerPositionFence {
46        &self.position
47    }
48
49    /// Returns the partition-local Fetch revision.
50    pub const fn fetch_revision(&self) -> u64 {
51        self.fetch_revision
52    }
53}
54
55/// Stable terminal reason one position resolution failed.
56#[derive(Clone, Copy, Debug, Eq, PartialEq)]
57pub enum AssignedConsumerPositionResolutionFailureKind {
58    /// The original resolution deadline elapsed.
59    DeadlineElapsed,
60    /// The driver rejected permanent request ownership.
61    DriverRejected,
62    /// Transport ownership terminated without a response.
63    Transport,
64    /// Kafka returned one exact nonzero signed error code.
65    Broker(i16),
66    /// The selected `ListOffsets` version could not preserve required semantics.
67    Compatibility,
68    /// The correlated response was structurally or semantically invalid.
69    InvalidResponse,
70    /// The generated or decoded response exceeded a configured bound.
71    ResponseTooLarge,
72    /// A positive throttle could not become an absolute deadline.
73    ThrottleDeadlineOverflow,
74}
75
76/// One exact terminal position-resolution event.
77#[derive(Debug, Eq, PartialEq)]
78pub struct AssignedConsumerPositionResolutionFailure {
79    pub(super) fence: AssignedConsumerPositionFence,
80    pub(super) kind: AssignedConsumerPositionResolutionFailureKind,
81}
82
83impl AssignedConsumerPositionResolutionFailure {
84    /// Borrows the exact named position generation.
85    pub const fn fence(&self) -> &AssignedConsumerPositionFence {
86        &self.fence
87    }
88
89    /// Returns the normalized terminal category.
90    pub const fn kind(&self) -> AssignedConsumerPositionResolutionFailureKind {
91        self.kind
92    }
93}
94
95/// Stable terminal reason the next Fetch could not be scheduled.
96#[derive(Clone, Copy, Debug, Eq, PartialEq)]
97pub enum AssignedConsumerFetchThrottleFailureKind {
98    /// A positive broker throttle could not become an absolute deadline.
99    DeadlineOverflow,
100}
101
102/// One exact terminal successful-Fetch throttle event.
103#[derive(Debug, Eq, PartialEq)]
104pub struct AssignedConsumerFetchThrottleFailure {
105    pub(super) fence: AssignedConsumerFetchFence,
106    pub(super) kind: AssignedConsumerFetchThrottleFailureKind,
107}
108
109impl AssignedConsumerFetchThrottleFailure {
110    /// Borrows the exact named Fetch generation.
111    pub const fn fence(&self) -> &AssignedConsumerFetchFence {
112        &self.fence
113    }
114
115    /// Returns the normalized terminal category.
116    pub const fn kind(&self) -> AssignedConsumerFetchThrottleFailureKind {
117        self.kind
118    }
119}
120
121/// Stable terminal reason one exact Fetch failed.
122#[derive(Clone, Copy, Debug, Eq, PartialEq)]
123pub enum AssignedConsumerFetchFailureKind {
124    /// The absolute Fetch deadline elapsed.
125    DeadlineElapsed,
126    /// The driver rejected permanent request ownership.
127    DriverRejected,
128    /// Transport ownership terminated without a response.
129    Transport,
130    /// Kafka returned one exact nonzero signed error code.
131    Broker(i16),
132    /// The selected Fetch version could not preserve required semantics.
133    Compatibility,
134    /// The correlated response was structurally or semantically invalid.
135    InvalidResponse,
136    /// The generated or decoded response exceeded a configured bound.
137    ResponseTooLarge,
138}
139
140/// One exact terminal Fetch event.
141#[derive(Debug, Eq, PartialEq)]
142pub struct AssignedConsumerFetchFailure {
143    pub(super) fence: AssignedConsumerFetchFence,
144    pub(super) kind: AssignedConsumerFetchFailureKind,
145}
146
147impl AssignedConsumerFetchFailure {
148    /// Borrows the exact named Fetch generation.
149    pub const fn fence(&self) -> &AssignedConsumerFetchFence {
150        &self.fence
151    }
152
153    /// Returns the normalized terminal category and exact broker code.
154    pub const fn kind(&self) -> AssignedConsumerFetchFailureKind {
155        self.kind
156    }
157}
158
159/// One application-visible failure transferred from the bounded FIFO.
160#[derive(Debug, Eq, PartialEq)]
161pub enum AssignedConsumerEvent {
162    /// One terminal position resolution.
163    PositionResolutionFailed(AssignedConsumerPositionResolutionFailure),
164    /// One terminal failure to schedule after a successful Fetch.
165    FetchThrottleFailed(AssignedConsumerFetchThrottleFailure),
166    /// One terminal Fetch execution.
167    FetchFailed(AssignedConsumerFetchFailure),
168}