#[non_exhaustive]pub enum SqlxBrokerError {
Show 17 variants
Connect {
source: Error,
},
Backend {
backend: String,
},
Sqlx {
subscription: String,
table: String,
row: &'static str,
statement: &'static str,
source: Box<Error>,
},
Schema {
subscription: String,
table: String,
row: &'static str,
statement: &'static str,
source: Box<Error>,
},
Dialect {
subscription: String,
table: String,
row: &'static str,
source: StatementError,
},
ServerTooOld {
subscription: String,
table: String,
row: &'static str,
server: String,
required: &'static str,
},
Declaration {
subscription: String,
table: String,
row: &'static str,
reason: String,
},
ConnectionLimit {
subscription: String,
limit: u32,
pool: u64,
threads: u64,
},
AlreadySubscribed {
subscription: String,
table: String,
row: &'static str,
},
BatchRolledBack {
subscription: String,
table: String,
row: &'static str,
},
LeaseLost {
subscription: String,
table: String,
row: &'static str,
id: String,
},
TransactionHeld {
subscription: String,
table: String,
row: &'static str,
id: String,
},
Listen {
subscription: String,
table: String,
row: &'static str,
source: Box<Error>,
},
Publish {
name: String,
table: String,
row: &'static str,
source: Box<Error>,
},
Header {
name: String,
table: String,
row: &'static str,
header: String,
},
NoRoute {
name: String,
},
Closed,
}Expand description
What can go wrong in the inbox broker.
Every variant about a subscription names the subscription, the table and the row type, so one line of a log says where to look.
§Examples
use ruststream::runtime::PublishError;
use ruststream_sqlx::prelude::*;
use ruststream_sqlx::{RepositoryPublisher, SqlxBrokerError};
use serde::Serialize;
use sqlx::Postgres;
#[derive(Serialize, Outgoing)]
#[outgoing(name = "exports")]
pub struct Export {
account: u64,
}
/// The status the service's HTTP endpoint answers when it schedules an export.
pub async fn schedule(exports: &RepositoryPublisher<Postgres, ExportJob>, export: &Export) -> u16 {
match exports.message(export).publish().await {
Ok(()) => 202,
// The service is shutting down: the client tries again later.
Err(PublishError::Publish(SqlxBrokerError::Closed)) => 503,
Err(error) => {
tracing::error!(%error, "the export was not scheduled");
500
}
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connect
connect could not take a connection from the pool.
Backend
connect found the pool on a database no built-in dialect serves: an AnyPool’s backend
whose feature is off.
Sqlx
A statement failed while the subscription ran.
Fields
Schema
A statement failed to prepare at startup: the table does not match the struct.
Preparing checks the names of the table and its columns, not the column types; a claimed row whose columns do not decode goes to the subscription’s decode-failure policy instead.
Fields
Dialect
The dialect refused to build a statement for the table.
Fields
source: StatementErrorWhat the dialect could not build.
ServerTooOld
The server is older than the statements of the subscription’s form need.
A subscription reads the server’s version when it opens, where its dialect asks for it:
MySQL claims rows with SKIP LOCKED in the row lock and lease forms, which MySQL 8.0.1 and
MariaDB 10.6 added, and a table in the advisory lock form shares that floor.
Fields
Declaration
The registration declared what the table cannot carry: a retry, or transactional mode at an isolation level its form cannot keep it at.
Fields
ConnectionLimit
A subscription on dedicated threads whose connections would take the service past the
broker’s connection_limit: the subscription does
not open, and the service does not start.
Fields
AlreadySubscribed
The connection already reads this queue: two subscriptions would compete for its rows.
Fields
BatchRolledBack
A settlement of a batch whose transaction an earlier settlement’s failure rolls back.
A batch that holds a row whose statement always fails rolls back and returns all of its rows on every attempt, until the service’s SQL or schema is fixed.
Fields
LeaseLost
A settlement in the lease form found its row under another lease, so it took no effect.
Ownership of a leased row ends with its lease, not with its holder. The subscription extends the lease of every delivery in work each half lease, so a lease runs out under a running handler only when its extensions fail or stop (the database out of reach, the subscription closed or the broker shut down). The handler then shares the row with the next claim, and the lease, the ownership token, only stops the late holder from settling.
A settlement whose statement fails keeps the row under its lease until the lease runs out, as a crash does; a delivery dropped unsettled releases its row at once.
Fields
TransactionHeld
A settlement in transactional mode found the delivery’s transaction still lent to its
handler’s Tx, which the handler moved somewhere that outlived it.
The settlement took no effect. The transaction ends when that Tx drops: its connection
closes, the server rolls back what the handler wrote, and the row returns to the queue. In
the lease form the row returns once its lease runs out, which the broker extends no more.
Fields
Listen
The broker with listen_notify could not listen on the channel of the subscription’s
table as it opened.
Fields
Publish
The service’s Publish failed.
Fields
Header
The publish carries a header the table cannot hold byte for byte, so it was refused.
Fields
NoRoute
No route leads the name to a table.
Closed
The broker was shut down; the handle outlived it.
Trait Implementations§
Source§impl Debug for SqlxBrokerError
impl Debug for SqlxBrokerError
Source§impl Display for SqlxBrokerError
impl Display for SqlxBrokerError
Source§impl Error for SqlxBrokerError
impl Error for SqlxBrokerError
Source§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()
Auto Trait Implementations§
impl !RefUnwindSafe for SqlxBrokerError
impl !UnwindSafe for SqlxBrokerError
impl Freeze for SqlxBrokerError
impl Send for SqlxBrokerError
impl Sync for SqlxBrokerError
impl Unpin for SqlxBrokerError
impl UnsafeUnpin for SqlxBrokerError
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
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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