net/adapter/net/cortex/error.rs
1//! Error type for CortEX adapter operations.
2
3use thiserror::Error;
4
5use super::super::redex::RedexError;
6
7/// Errors produced by [`super::CortexAdapter`] operations.
8#[derive(Debug, Error)]
9pub enum CortexAdapterError {
10 /// Underlying RedEX storage error.
11 #[error("redex: {0}")]
12 Redex(#[from] RedexError),
13
14 /// The adapter has been closed.
15 #[error("adapter closed")]
16 Closed,
17
18 /// The fold task has stopped (first fold error under
19 /// [`super::FoldErrorPolicy::Stop`]). Holds the RedEX sequence
20 /// at which the fold stopped.
21 #[error("fold stopped at seq {seq}")]
22 FoldStopped {
23 /// The RedEX sequence of the event whose fold returned an error.
24 seq: u64,
25 },
26
27 /// `wait_for_seq` was asked to wait past a seq the fold task
28 /// will never reach: the task halted (close, Stop-policy halt,
29 /// retention-evicted tail lag) with the folded watermark in
30 /// `folded_through`. Pre-fix this manifested as
31 /// `wait_for_seq` silently returning `()` and the caller
32 /// reading state that did not reflect the requested seq.
33 #[error("fold stopped before seq {wanted}; folded through {folded_through:?}")]
34 FoldStoppedBeforeSeq {
35 /// The seq the caller was waiting for.
36 wanted: u64,
37 /// The highest seq the fold task processed before
38 /// stopping; `None` if it stopped without processing
39 /// anything.
40 folded_through: Option<u64>,
41 },
42
43 /// `open` was called with a `StartPosition` that requires
44 /// externally-rehydrated state — `FromSeq(n)` for `n > 0` or
45 /// `LiveOnly`. Callers using these positions must construct
46 /// the adapter via [`super::CortexAdapter::open_from_snapshot`]
47 /// instead so the watermark and `state` are properly anchored
48 /// to the prior events the adapter is going to skip.
49 ///
50 /// Accepting these positions in `open` would set
51 /// `initial_watermark = start_seq - 1`, making
52 /// `wait_for_seq(k)` for `k <= start_seq-1` return immediately
53 /// — the adapter would claim those seqs were "applied" while
54 /// `state` had never seen them.
55 #[error("StartPosition::{0} requires open_from_snapshot, not open")]
56 InvalidStartPosition(&'static str),
57}