#[non_exhaustive]pub enum TrackedPublishError<PublishError> {
Outbox(OutboxError),
Publish(PublishError),
}Expand description
A publish through wrap that failed: the outbox did not record the
message, or the publisher it wraps did not send it.
§Examples
use ruststream::runtime::PublishError;
use ruststream_sqlx::outbox::{OutboxError, TrackedPublishError};
pub async fn serve(pool: PgPool) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let tracking = outbox! { pool: pool, "orders" => OrderOutbox };
let broker = MemoryBroker::new().bindable();
let egress = broker.bind(Publish);
let running = RustStream::new(AppInfo::new("orders", "0.1.0"))
.with_broker(broker, |b| {
b.include(fulfil);
})
.start()
.await?;
let publisher = tracking.wrap(running.publisher(egress).await?);
// The status an HTTP endpoint answers an order with.
let status = match publisher.message(&OrderPlaced { id: 7 }).publish().await {
Ok(()) => 202,
// Recorded but not sent: the next startup sends it.
Err(PublishError::Publish(TrackedPublishError::Publish(_))) => 202,
// Neither recorded nor sent: the client sends the order again.
Err(PublishError::Publish(TrackedPublishError::Outbox(OutboxError::Record { .. }))) => 503,
Err(_) => 500,
};
tracing::info!(status, "order answered");
running.shutdown().await?;
Ok(())
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Outbox(OutboxError)
The record was not written, so the message was not sent.
Publish(PublishError)
The wrapped publisher’s error. The record stays unprocessed, and the next startup publishes it again.
Trait Implementations§
Source§impl<PublishError: Debug> Debug for TrackedPublishError<PublishError>
impl<PublishError: Debug> Debug for TrackedPublishError<PublishError>
Source§impl<PublishError> Display for TrackedPublishError<PublishError>where
PublishError: Display,
impl<PublishError> Display for TrackedPublishError<PublishError>where
PublishError: Display,
Source§impl<PublishError> Error for TrackedPublishError<PublishError>
impl<PublishError> Error for TrackedPublishError<PublishError>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl<PublishError> !RefUnwindSafe for TrackedPublishError<PublishError>
impl<PublishError> !UnwindSafe for TrackedPublishError<PublishError>
impl<PublishError> Freeze for TrackedPublishError<PublishError>where
PublishError: Freeze,
impl<PublishError> Send for TrackedPublishError<PublishError>where
PublishError: Send,
impl<PublishError> Sync for TrackedPublishError<PublishError>where
PublishError: Sync,
impl<PublishError> Unpin for TrackedPublishError<PublishError>where
PublishError: Unpin,
impl<PublishError> UnsafeUnpin for TrackedPublishError<PublishError>where
PublishError: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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