Skip to main content

EventSchema

Struct EventSchema 

Source
pub struct EventSchema { /* private fields */ }
Expand description

The payload format of one event type: its current version and the steps that bring older payloads up to it. Events are stored as written and never changed; readers upcast them.

Made with Domain::event; its methods return it, so they chain: shop_domain.event("ItemAdded", 2).upcast(1, |mut d| { d["qty"] = json!(1); d }); or shop_domain.event("CustomerRegistered", 1).personal(&["email"], |_, id| id.to_owned());. A subject function gets the payload and the aggregate’s ID, e.g. |d, _| d["customerId"].as_str().unwrap_or_default().to_owned().

Implementations§

Source§

impl EventSchema

Source

pub fn personal( self, fields: &[&str], subject: impl Fn(&Value, &str) -> String + Send + Sync + 'static, ) -> Self

Keeps these top-level fields in the vault, as personal data of the subject subject returns from the payload and the aggregate’s ID (see EventSchema for examples). Events then hold only references; the kernel hands the values to workers and to listeners allowed to read them, until an event erases the subject.

Source

pub fn erases( self, subject: impl Fn(&Value, &str) -> String + Send + Sync + 'static, ) -> Self

Makes this an erasing event: it deletes every vault value of the subject subject returns, in every stream, and the snapshots that may hold them. Read models should drop the subject’s data when they see it; rebuilt, they read null.

Source

pub fn upcast( self, from: u32, step: impl Fn(Value) -> Value + Send + Sync + 'static, ) -> Self

Turns a payload of version from into one of version from + 1: step gets the old payload and returns the new one. Declare one step per older version.

§Panics

If from is not a version below the current one.

Auto Trait Implementations§

§

impl Forget for EventSchema

§

impl Freeze for EventSchema
where *const ArcInner<DomainInner> is !null: Freeze, PhantomData<ArcInner<DomainInner>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for EventSchema

§

impl RefUnwindSafe for EventSchema

§

impl Send for EventSchema
where Arc<DomainInner>: Send, RawVecInner: Send,

§

impl Sync for EventSchema
where Arc<DomainInner>: Sync, RawVecInner: Sync,

§

impl Unpin for EventSchema
where Arc<DomainInner>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for EventSchema
where *const ArcInner<DomainInner> is !null: UnsafeUnpin, PhantomData<ArcInner<DomainInner>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

§

impl UnwindSafe for EventSchema
where Arc<DomainInner>: UnwindSafe, RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more