Enum PostgresEventStoreError
#[non_exhaustive]pub enum PostgresEventStoreError {
Show 13 variants
Driver(Error),
PositionOutOfRange {
value: i64,
},
EventType(InvalidEventType),
Tag(InvalidTag),
MissingIdentity,
MalformedIdentity {
len: usize,
},
UnstampedEvent {
position: SequencePosition,
},
Worker(JoinError),
NoRuntime,
UnreadableTransactionId,
OriginPositionOutOfRange {
position: SequencePosition,
},
StoredGuard {
first: SequencePosition,
source: GuardCodecError,
},
GroupOrder(GroupOrderError),
}Expand description
How PostgresEventStore fails for
its own reasons.
The decoding variants are not defensive padding. A row is written by one
version of this adapter and read back by another, and the contract types
enforce invariants that the Postgres column types do not: position is
bigint, which is signed and admits 0 and negatives, while
SequencePosition is a NonZeroU64;
event_type and tag are text, which admits control characters and
over-long values that EventType and
Tag reject. Every one of those is a real row a
real database can hand back, and the alternative to a variant is a panic in a
library.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Driver(Error)
The driver, the pool or the server rejected the work.
This is the common case and it is deliberately not flattened into
per-SQLSTATE variants: sqlx::Error::Database already exposes the code
through
DatabaseError::code, and a variant
per code would be a second, worse copy of that.
PositionOutOfRange
A row carried a position outside the contract’s domain.
bigint is signed and admits zero; SequencePosition is a NonZeroU64.
The gap between the two is exactly this variant.
EventType(InvalidEventType)
A row carried an event_type that no longer passes validation.
Tag(InvalidTag)
A row carried a tag that no longer passes validation.
MissingIdentity
store_meta has no store_id row.
Almost always means migration 1 has not been applied to the schema this
pool resolves against. Spelled as its own variant rather than as a
Driver error because “the schema is not there” and “the server refused
the query” send a reader to entirely different places, and at 2am the
difference is the whole diagnosis.
MalformedIdentity
The store_id row is not sixteen bytes.
StoreId is [u8; 16] exactly, and the
schema’s CHECK says so — so reaching this means something wrote the row
without going through either.
UnstampedEvent
A row carries no EventId.
Every event this store appends is stamped with origin_store and
origin_position in the same statement that inserts it, so a row missing
either was written by something other than this adapter. Reported rather
than papered over with a synthesised id, because a synthesised EventId
is a replication identity this store has no authority to mint.
Fields
position: SequencePositionWhere the unstamped row sits.
Worker(JoinError)
The task a read stream handed its work to did not finish.
read spawns the cursor’s opening onto the runtime rather than polling
it inline, so that the read’s state is fixed no later than the first poll
(ES-11) rather than whenever the caller next gets round to polling. A
spawned task can panic or be cancelled, and neither is something the
caller can act on — but ending the stream silently would look exactly
like an empty log, which is why this is an error rather than a None.
NoRuntime
read was polled outside a tokio runtime.
The stream needs a runtime to hand its work to, and read is not async
— deliberately, because nesting the stream inside a future drops + Send
from it — so nothing forces the caller to be on one. Reported rather than
panicked: a library that panics on a legitimate call pattern has made the
caller’s mistake into its own crash.
UnreadableTransactionId
A row’s xact_id could not be read as the mechanism’s frontier type.
The visibility mechanism stores pg_current_xact_id() beside each row
and compares it against pg_snapshot_xmin(pg_current_snapshot()). A
value that will not decode means the column is not the one this adapter
wrote, which is a schema disagreement rather than a transient fault —
worth its own name because every other symptom of it is a wrong answer
rather than an error.
OriginPositionOutOfRange
sync only.An ingested event’s origin position is past the largest a bigint
holds, so it cannot be stored. Refused before the transaction opens.
Produced only by ingest, behind sync. The enum is
#[non_exhaustive], so a variant that appears under a feature breaks
no exhaustive match.
Fields
position: SequencePositionThe origin position as the peer sent it.
StoredGuard
sync only.The guard of a write group could not be put into group_guard on its
way in, or read back out of it (#420).
On the way in the ingest’s transaction is rolled back, so nothing in
the call was written. On the way out the stored bytes are not a guard
this build’s codec reads, which only a damaged schema or a newer
build’s format holds; the group is not forwarded without it. Behind
sync, for the reason OriginPositionOutOfRange
is.
Fields
first: SequencePositionThe write group the guard belongs to.
source: GuardCodecErrorWhy the codec refused it.
GroupOrder(GroupOrderError)
sync only.The group read handed its page builder a row naming a write group it had already passed, so the log cannot be paged in whole groups.
The read orders its rows by group, so no schema this adapter wrote
produces one; a hand-edited write_group can. Behind sync, for the
reason OriginPositionOutOfRange is.
Trait Implementations§
§impl Classify for PostgresEventStoreError
Available on crate features event-store and sync only.SY-36’s class for each way this adapter fails.
impl Classify for PostgresEventStoreError
event-store and sync only.SY-36’s class for each way this adapter fails.
Exhaustive over this crate’s own enum, with no wildcard, so a new variant does not compile until somebody decides its class. A driver failure is transient when the server aborted or never started the work and time or an operator cures it: the network, the pool, a serialisation failure, a deadlock, an administrator’s shutdown, or exhausted resources. Every other driver failure, and every decoding variant, fails the same way again.
§fn class(&self) -> FailureClass
fn class(&self) -> FailureClass
§impl Debug for PostgresEventStoreError
impl Debug for PostgresEventStoreError
§impl Display for PostgresEventStoreError
impl Display for PostgresEventStoreError
§impl Error for PostgresEventStoreError
impl Error for PostgresEventStoreError
§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
§impl From<Error> for PostgresEventStoreError
impl From<Error> for PostgresEventStoreError
§impl From<GroupOrderError> for PostgresEventStoreError
impl From<GroupOrderError> for PostgresEventStoreError
§fn from(source: GroupOrderError) -> Self
fn from(source: GroupOrderError) -> Self
§impl From<JoinError> for PostgresEventStoreError
impl From<JoinError> for PostgresEventStoreError
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresEventStoreError
impl !UnwindSafe for PostgresEventStoreError
impl Freeze for PostgresEventStoreError
impl Send for PostgresEventStoreError
impl Sync for PostgresEventStoreError
impl Unpin for PostgresEventStoreError
impl UnsafeUnpin for PostgresEventStoreError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more