Expand description
reliar-core is the pure envelope/message model every Reliar crate builds on: identity
newtypes, the Message contract, a validated Headers map, typed Metadata, and the
Envelope/SerializedEnvelope pair that carries them (SRS §9–§17).
§Guarantees
-
Pure. No storage or transport dependency: no sqlx, no broker client, no routing concept (a Kafka partition key, a
RabbitMQexchange, a NATS subject). Every other Reliar crate depends on this one; this one depends on nothing Reliar-specific (ADR 0002). -
One source of truth for framework metadata.
Envelope::metadatais canonical for every concept Reliar understands. A value here is never duplicated intoEnvelope::headers, and Reliar never reads a framework value back out of headers (ADR 0004).Headersreserves the entirereliar-prefix, case-insensitively, so a custom header can never collide with — or be mistaken for — a framework one. -
Message identity never depends on
std::any::type_name::<T>()or a module path. AMessage’sMessageTypecomes from its ownTYPE/VERSIONconstants, so renaming or moving the Rust type is safe and two distinct types sharing them render identically (ADR 0010). -
One envelope type for both sides of a serialization boundary.
Envelope<T>andSerializedEnvelope(= Envelope<bytes::Bytes>) are the same generic type; converting between them (Envelope::map_body) can never drop or duplicate a field (ADR 0003). -
Owns vocabulary every capability shares, nothing storage/transport-specific. An item belongs here when it names no storage engine, broker or transport routing concept and more than one Reliar capability needs it to talk to another — never merely because it is small (ADR 0032).
Every public error is a hand-rolled, #[non_exhaustive] enum with a wired
std::error::Error::source — no thiserror, no anyhow. Debug on payload-bearing types
elides the bytes; no Display here ever prints a payload, a header value, or a credential.
Structs§
- Content
Type - A validated MIME type. Owned by the
Serializerthat produced a payload — never chosen at the call site (ADR 0010). - Conversation
Id - Groups every message in one business conversation. Defaults to the id of the message
that starts it (see
crate::EnvelopeBuilder::build), so an un-correlated message is the root of its own conversation. - Correlation
Id - Application/business workflow correlation id — distinct from
ConversationId(Reliar’s own conversation root) and acausation_id(the direct parent message). Capped atSelf::MAX_LENbytes: it lands in atextcolumn read on every claim (§11). - Correlation
Metadata - Correlation and conversation identity for one envelope.
- Delivery
Metadata - Serialization and delivery hints for one envelope.
- Endpoint
Address - An opaque, transport-interpreted address string (a queue name, a subject, a service name —
Reliar does not care which). Capped at
Self::MAX_LENbytes. - Envelope
- An envelope: a typed or serialized body plus the metadata Reliar understands and the custom
headers it does not (§9).
Envelope != OutboxRecord != InboxRecord(§17) — nothing here carries delivery state (attempts, leases, dead-letter bookkeeping). - Envelope
Builder - Builds an
Envelope<T>. Obtained fromEnvelope::builder. - Headers
- Application-defined metadata Reliar does not understand: a validating newtype, never a
HashMapalias and never exposed throughDeref(ADR 0011). Reserves the entirereliar-prefix (case-insensitive) so framework metadata is never duplicated here — seeMetadatafor the one canonical source of truth (ADR 0004, §14). - Json
Serializer - The default
Serializer: JSON viaserde_json. Ships behind the defaultjsonfeature; disable it to supply a different wire format (ADR 0010). - Message
Id - Uniquely identifies one envelope end-to-end: enqueue, storage row, wire message, and, if it fails permanently, the dead entry.
- Message
Type - A message’s name and version, carried separately so a query can filter a name across every
version (§24). Renders as
"{name}.v{version}"via itsDisplayimpl. - Metadata
- Canonical, typed framework metadata: the single source of truth. No value here is ever
duplicated into
Headers(ADR 0004). - Request
Id - Correlates an envelope back to the inbound request (HTTP call, RPC, CLI invocation) that caused it, so an outbound message can be traced to its trigger.
- Routing
Metadata - Transport-independent routing only. Kafka partition keys,
RabbitMQexchanges and NATS subject options are transport concepts and SHALL NOT appear here (§12). - Trace
Context - W3C Trace Context, carried verbatim. Reliar never invents or re-derives it (ADR 0004, ADR 0020): a transport mapper writes these from an active span and reads them back on decode.
Enums§
- Content
Type Error ContentType::parsefailures.- Failure
Kind - Whether a failure is worth retrying.
- Header
Error Headers::insertfailures.- IdError
- Validation failures shared by every capped string identity newtype in
reliar-core. - Json
Error JsonSerializerfailures.Displaynames the operation, the error class (serde_json::error::Category), and the line/column — neverserde_json::Error’s own message, which for a data error embeds a fragment of the value it rejected (e.g.invalid type: string "sk-live-…", expected u64). The full underlying error, message included, is still reachable viastd::error::Error::sourcefor a caller that deliberately wants it — that caller’s own logging is then responsible for §33.- Settings
Error - Why a
*Settings::from_envcall failed.OutboxSettings::from_env(reliar-outbox) was the first caller; every provider’s ownfrom_envreturns this same type (contract §7 I3).
Traits§
- Classify
- Implemented by every
crate::Publisher::ErrorandOutboxStore::Error(reliar-outbox) so a dispatcher can decide retry vs. dead without a downcast. Carried by the error type, not by the publisher: the error value is what crosses aJoinSetboundary into the dispatcher, so it must carry its own verdict (ADR 0008). - Envelope
Mapper - Converts a
SerializedEnvelopeto and from one transport’s native message typeM. - Message
- A type that can be built into an
Envelopeand persisted or published. - Publisher
- The wire side of the outbox. One provider implements this per transport.
- Serializer
- Converts a typed
Messagebody to and from bytes. Lives inreliar-core: it touches neither storage nor transport (ADR 0010).
Type Aliases§
- Serialized
Envelope - The persistence/transport form: an envelope whose body has already been serialized to bytes.