Skip to main content

kafka_client_engine/consumer/assigned_host/next_event/
error.rs

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