pub struct AppContext {
pub event_context: EventContext,
pub idempotency_key: Option<String>,
}Expand description
Application Context for a single command/query invocation.
AppContext carries the cross-cutting metadata required by the
application layer when handling one logical request. It is created at the
system boundary (HTTP handler, message consumer, scheduled job) and
passed unchanged through the command/query bus down to the handler so
that downstream domain events can be tagged with the correct provenance.
The context bundles two concerns:
- Business / tracing context (
EventContext): correlation id, causation id, and the actor (type and id) responsible for the operation. These fields are persisted alongside emitted domain events so that the full causal chain can be reconstructed for auditing and debugging. - Idempotency key (
idempotency_key): an optional infrastructure-level token used by the API or messaging layer to deduplicate retried submissions. The application/domain layers do not interpret this value — they merely propagate it to the infrastructure boundary.
§Examples
use eventide_application::context::AppContext;
use eventide_domain::domain_event::EventContext;
let ctx = AppContext {
event_context: EventContext::builder()
.maybe_correlation_id(Some("cor-123".into()))
.maybe_causation_id(Some("cau-abc".into()))
.maybe_actor_type(Some("user".into()))
.maybe_actor_id(Some("u-1".into()))
.build(),
idempotency_key: Some("idem-xyz".into()),
};Fields§
§event_context: EventContextBusiness context: tracing identifiers, audit subject, causal lineage.
idempotency_key: Option<String>Optional idempotency key. When None, the upper layer or
infrastructure decides whether and how to apply idempotent semantics.
Trait Implementations§
Source§impl Clone for AppContext
impl Clone for AppContext
Source§fn clone(&self) -> AppContext
fn clone(&self) -> AppContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AppContext
impl Debug for AppContext
Source§impl Default for AppContext
impl Default for AppContext
Source§fn default() -> AppContext
fn default() -> AppContext
Returns the “default value” for a type. Read more
Source§impl From<&SerializedEvent> for AppContext
impl From<&SerializedEvent> for AppContext
Source§fn from(event: &SerializedEvent) -> Self
fn from(event: &SerializedEvent) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for AppContext
impl RefUnwindSafe for AppContext
impl Send for AppContext
impl Sync for AppContext
impl Unpin for AppContext
impl UnsafeUnpin for AppContext
impl UnwindSafe for AppContext
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