Expand description
The core prelude plus everything a Redis Streams service writes.
The broker, the RedisStream descriptor and its options, the group seek types with the
delivery and batch contexts that carry them, this form’s Publish policy, and the
transaction, position and seek capabilities.
§Examples
use ruststream_fred::stream::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Outgoing)]
#[outgoing(name = "orders.priced")]
struct Order {
id: u64,
}
#[subscriber(RedisStream::new("orders").group("workers"), reply)]
async fn price(orders: &[Order]) -> Result<Vec<Order>, HandlerOutcome> {
Ok(orders.iter().map(|order| Order { id: order.id }).collect())
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
// One batch's replies land together, as one MULTI / EXEC block.
b.include(price.batch(nonzero!(32)))
.out_reply(TransactionalPublish)
.transactional();
},
)
}Two vocabularies that do not mix. A handler body imports ruststream::prelude::* and bounds an
injected slot with the broker capability trait it needs (Out<impl Publisher>, Out<impl TransactionalPublisher>); a routes file globs this prelude and names the policy by its
mount-site word, the same word on every form.
The Prelude page shows each form’s prelude in a service.
A file that also globs another form’s prelude sees an ambiguous Publish; use
crate::prelude and write stream::Publish there.
Re-exports§
pub use super::Publish;pub use super::RedisStream;pub use super::StreamStart;pub use super::TransactionalPublish;pub use crate::context::PipelineContext;pub use crate::context::PoolContext;pub use crate::context::StreamBatchContext;pub use crate::context::StreamContext;pub use crate::context::keys;pub use crate::pipeline::Bindable;pub use crate::pipeline::InRound;pub use crate::pipeline::RedisPipelineSteps;pub use crate::DelayedRetry;pub use crate::PARTITION_KEY_HEADER;pub use crate::RedisBroker;pub use crate::RedisGroupPosition;pub use crate::RedisGroupSeeker;pub use crate::RedisPublishOptions;pub use crate::RedisPublishSteps;pub use crate::RedisSubscribeExt;
Macros§
Structs§
- AppInfo
- Service-level metadata, surfaced to the
AsyncAPIgenerator as the specInfoobject. - Bytes
Mut - The buffer the crate’s byte-producing surfaces speak: what a
Codecreturns, what aSerializedvalue writes into, and the payload a publisher that declaredTakeis handed. - Caller
Name - The destination form of a type declaring no name: the call site names the destination.
- Context
- Per-delivery context, threaded through middleware and into the handler.
- Ctx
- Extractor that injects one broker context field into a handler, by its key.
- Default
Slot - The implicit marker of a single unnamed
Out<impl Publisher>parameter. - Failure
Policies - The pair of failure policies a subscriber carries: one for a handler panic, one for a decode
failure. Threaded from the def to the dispatch loop alongside the
Workerspolicy. - Fixed
Name - The destination form of a type declaring one literal name: the name is fixed, so the publish builder resolves the destination without asking the call site.
- ForReply
- The kind of a reply position: the transform reads the delivery it answers, as a
PublishContextover the handler’s own context typeC. - ForSlot
- The kind of an
Outslot position: the transform reads aSlotContext, which names the slot and nothing else. - Handler
Outcome - The settlement of one dispatched message: the broker status the dispatcher acts on, plus an optional post-settle continuation.
- Header
Map - Case-insensitive map of broker-message headers.
- Headers
- Extractor that parses the delivery headers into a typed contract before the body runs.
- Main
Runtime - The runtime the app runs on, as a handler reaches it:
Ctx(main): Ctx<MainRuntime>as a parameter, orContext::main_runtime. - Message
- One incoming message together with its decoded typed header contract.
- Name
- The default
SubscriptionSource: subscribe by name string via theSubscribecapability. - Name
Template - The destination form of a type declaring a name template: the call site binds every placeholder through the setters generated from it, and the name is rendered per publish.
- Names
- The transform names the destination. A position offers this only where the destination is not already declared, so a declaration and the wire cannot disagree.
- NoHeaders
- The header contract of a message that carries no typed headers.
- Out
- The marker a handler signature uses to receive an injected publisher:
Out(out): Out<impl Publisher>bindsoutto a live publisher inside the body. - Outgoing
Message Metadata - One message a handler publishes, as declared for the
AsyncAPIdocument. - Outs
- The injections arena a slot body receives: its entries mirror the marker tuple the body
declared, and
getpicks one by marker. - Reads
- The transform reads the destination and leaves it alone. What almost every transform declares, and what every position offers.
- Reply
- The marker of a handler’s reply position:
.out(Reply, policy)names the publish policy the value areply("dest")handler returns leaves through. - Retry
- The marker of a registration’s deferred-retry slot:
.out(Retry, policy)names the publish policy aretry_aftercopy leaves through. - Router
- A statically-typed, lazily-bound group of handler registrations, not attached to any broker.
- Running
App - A started service, handed out by
RustStream::start. - Rust
Stream - The top-level application object.
- Serialized
Reply - The serialized reply wire: the value already carries its bytes
(
Serializedreplies), and they leave as they are, with no codec. - Serialized
Wire - The serialized wire of a typed publish: the value already carries its bytes
(
Serialized), and they leave as they are, with no codec. - Slot
- One arena entry: the wired live value of the marker
M, plus the publish path the include site gave it - its encode codec and the pipeline every message leaving the slot travels. - Solo
Deserialized - The single self-deserializing input:
In = F<'_>for aDeserializedF. - State
- Extractor that injects a piece of the shared application state into a handler.
- TlsConfig
- TLS configuration for a client.
- Unnamed
- The stand-in a definition carries while its subscription has no name yet.
- With
Headers - The header contract of a message whose headers are the typed struct
H. - Workers
- Concurrency policy for one subscriber’s dispatch loop, declared with the
workers(..)orthreads(..)macro argument (orWorkers::sequentialby default).
Enums§
- Failure
Policy - What a subscriber does when it cannot process a message.
- TlsConnector
- An enum for interacting with various TLS libraries and interfaces.
- Wire
Bytes - Where a
Serializedvalue’s bytes are: in the buffer it was handed, or in the value itself.
Traits§
- App
- The functional surface of a built
RustStreamservice: run it, and read the metadata theAsyncAPIgenerator and the generated CLI need. - Broker
- An unconnected broker: configuration captured, no I/O performed yet.
- Context
Kind - What one publish position hands its transforms.
- Deserialized
- A type that deserializes itself from the payload bytes:
Deserializemeans the framework’s codec does it,Deserializedmeans it is already done by the user’s own type. - From
Context - A value resolved from the per-delivery
Contextand shared state, ready to be passed to a handler as a parameter. - FromRef
- Produces a value from a reference to the shared application state
S. - Handle
- The one body contract of the manual path: every axis of the form matrix is a defaulted parameter the impl pins.
- Incoming
Message - A message delivered by a
Subscriber. - Input
- A
Handleinput spelling: a decodedT, aDeserializedtype, aMessage<H, P>pair, a value the delivery already holds (Carries), or a batch (slice) of any of them. - MapPublisher
- Replaces the publish policy of the position a mount chain named last, keeping every step the chain already filled: the hook a broker crate layers its own publisher settings on.
- Message
Headers - Declares a message type’s typed header contract.
- Message
Info - Metadata about a message type, used to name and describe it in an
AsyncAPIdocument. - Message
Wire - The wire of a typed publish value: whether the resolved codec serializes it.
- OutEntry
- What one arena entry is, stated as the mount’s choices rather than spelled out: the bound
marker
M, and the wired value, codec and publish path the include site gave it. - OutMessages
- A declared message set’s
AsyncAPIcontribution: oneOutgoingMessageMetadataentry per member, each read off the member’s own declaration. - OutSlot
- A slot marker: the identity of one
Outinjection. - Outgoing
Destination - Declares where a message type is sent.
- Owned
Transactions - A publisher that opens caller-owned, client-buffered transactions.
- Positioned
- A delivered message that knows its own position in the broker’s replayable log.
- Publish
Ext - The publish builder on any
Publisher:message(..), the one entry point of a publish. - Publish
Policy - The declaration half of a publisher: pure policy, no connection, no publish surface.
- Publish
Transform - A static, compile-time publish transform: mutates an
Outgoingbefore it is sent, with read access to whatever its position hands it. - Published
Through - Membership of a message type in a slot marker’s
#[publishes(..)]dictionary: the type may leave through a slot identified bySlot. - Publisher
- A producer that sends messages into the broker.
- Reply
Shape - The shape and wire of a reply value: what payload it publishes, what typed header contract rides it, and whether the framework’s codec serializes it.
- Request
Reply - A publisher that supports synchronous request / reply messaging.
- Router
Def - A mountable group of handler registrations.
- Seeker
- A clonable handle that repositions one subscription, minted by
Seekable::seeker. - Serialized
- A value that owns its byte layout:
Serializemeans the framework’s codec does the work,Serializedmeans the type produces the bytes itself. - Subscriber
Settings - The declarative settings, chainable on a
#[subscriber]definition and on the builder alike. - Transaction
- A client-buffered transaction that owns its buffer, opened by
OwnedTransactions::transaction. - Transactional
Publisher - A publisher that supports broker-side transactions.
Functions§
- subscriber
- Binds a
Handlebody to its subscription source; the one mounting verb of the manual path.
Type Aliases§
- Str
- The owned string of the message path: a destination name, a header key.