pub struct StdioPublisher { /* private fields */ }Expand description
Publishes messages to standard output.
The line format is the client’s own. A line is text, ends at a newline, and the reader trims it, so a payload that is not UTF-8, holds a newline or begins or ends with whitespace (and any message with headers) travels in the text-safe envelope. The client silently drops empty lines, so an empty payload is rejected here instead.
A publish carries no per-message settings: a line on standard output takes a key and a
payload and nothing else, so Publisher::Options is the unit type and the publish builder
gains no step from this crate.
Standard output reaches the next process in the pipeline and never this process’s own
standard input, so a registration that defers a delivery names where the copy goes, with
.out_retry(Publish).to(key) or a transform that names one per delivery; one that names
neither refuses to start. The
StdioPublish
page shows it in a service.
§Examples
use ruststream_sea_file::stdio::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
struct Job {
id: u64,
}
#[derive(Debug, Outgoing, Serialize)]
#[outgoing(name = "results")]
struct Done {
id: u64,
}
#[subscriber("jobs", reply)]
async fn work(job: &Job) -> Done {
tracing::info!(job.id, "done");
Done { id: job.id }
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("pipeline", "0.1.0")).with_broker(StdioBroker::new(), |b| {
b.include(work).out_retry(Publish).to("jobs.retry");
})
}Trait Implementations§
Source§impl Clone for StdioPublisher
impl Clone for StdioPublisher
Source§impl Debug for StdioPublisher
impl Debug for StdioPublisher
Source§impl Publisher for StdioPublisher
impl Publisher for StdioPublisher
Source§type Payload = Lend
type Payload = Lend
A line on standard output is written from the bytes and keeps nothing: the client’s
send_to takes a slice, and the text-safe envelope is a buffer of this crate’s own.
Source§type Error = SeaFileError
type Error = SeaFileError
publish.Source§type Options = ()
type Options = ()
QoS, a priority, an ordering key, whatever this
transport lets one message differ from the next in. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for StdioPublisher
impl !UnwindSafe for StdioPublisher
impl Freeze for StdioPublisher
impl Send for StdioPublisher
impl Sync for StdioPublisher
impl Unpin for StdioPublisher
impl UnsafeUnpin for StdioPublisher
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<P> PublishExt for P
impl<P> PublishExt for P
Source§fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
#[derive(Outgoing)] value, encoded with the crate’s
default codec (name another one with with_codec(..)). A
Serialized value’s bytes leave as they are instead - the wire is
the type’s own (MessageWire), and no codec runs on it. Read moreSource§fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
TransactionScope that
owns it. Read moreSource§fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
TypedTransaction that owns it. Read more