Expand description
The core prelude plus everything a service mixing all three Redis forms writes.
The broker, every descriptor and publish policy, the seek types, the per-delivery and
batch contexts with their keys, and the crate::stream, crate::list and
crate::pubsub modules. The policies keep their prefixed names, so a mixed file writes
stream::Publish beside pubsub::Publish. The
Prelude
page shows the form preludes and this one in a service.
§Examples
use ruststream_fred::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Order {
id: u64,
}
#[derive(Serialize, Outgoing)]
#[outgoing(name = "orders.shipped")]
struct Shipped {
id: u64,
}
#[subscriber(RedisStream::new("orders").group("workers"), reply)]
async fn ship(order: &Order) -> Shipped {
Shipped { id: order.id }
}
#[subscriber(RedisList::new("invoices").reliable())]
async fn invoice(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "invoicing");
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
// A stream in, a Pub/Sub broadcast out: the form prefix says which `Publish`.
b.include(ship).out_reply(pubsub::Publish::default());
b.include(invoice);
},
)
}A service on a single form globs that form’s prelude instead, which carries Publish under the
uniform mount-site name and only the capabilities that form has.
Re-exports§
pub use crate::context::PipelineContext;pub use crate::context::PoolContext;pub use crate::context::PubSubContext;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::PubSubMode;pub use crate::RedisBroker;pub use crate::RedisGroupPosition;pub use crate::RedisGroupSeeker;pub use crate::RedisList;pub use crate::RedisListPublish;pub use crate::RedisPubSub;pub use crate::RedisPubSubPattern;pub use crate::RedisPubSubPublish;pub use crate::RedisPublish;pub use crate::RedisPublishOptions;pub use crate::RedisPublishSteps;pub use crate::RedisStream;pub use crate::RedisSubscribeExt;pub use crate::StreamStart;pub use crate::list;pub use crate::pubsub;pub use crate::stream;
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.