Skip to main content

kafka_client_engine/consumer/assigned_host/recv/
error.rs

1//! Stable failures for notification-backed batch observation.
2
3/// Stable reason an assigned-consumer receive operation terminated.
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub enum AssignedConsumerRecvErrorKind {
6    /// The synchronized engine host can no longer expose retained batches.
7    HostUnavailable,
8    /// A non-semantic observation mechanism violated its ownership contract.
9    InternalInvariant,
10}
11
12/// Failure while waiting for one already-authorized batch.
13#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14pub struct AssignedConsumerRecvError {
15    kind: AssignedConsumerRecvErrorKind,
16}
17
18impl AssignedConsumerRecvError {
19    pub(super) const fn host_unavailable() -> Self {
20        Self {
21            kind: AssignedConsumerRecvErrorKind::HostUnavailable,
22        }
23    }
24
25    pub(super) const fn internal_invariant() -> Self {
26        Self {
27            kind: AssignedConsumerRecvErrorKind::InternalInvariant,
28        }
29    }
30
31    /// Returns the stable receive-failure category.
32    pub const fn kind(&self) -> AssignedConsumerRecvErrorKind {
33        self.kind
34    }
35}
36
37impl std::fmt::Display for AssignedConsumerRecvError {
38    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39        write!(
40            formatter,
41            "assigned-consumer receive failed: {:?}",
42            self.kind
43        )
44    }
45}
46
47impl std::error::Error for AssignedConsumerRecvError {}