pub struct Domain { /* private fields */ }Expand description
A domain: a name that scopes its aggregates, commands and events, lowercase by convention
(orders) like aggregates, while message types are capitalized (orders.PlaceOrder). Both
cases are valid; names are case-sensitive. Types are unique within a domain; elsewhere they
are named domain.Type. Cloning gives another handle to the same domain.
Make it with domain: let shop_domain = domain("shop");. A domain remembers the
aggregates, read models and reactors created through it, so that an app runs all of them
(see crate::Kernable::app); they live as long as the domain does.
Implementations§
Source§impl Domain
impl Domain
Sourcepub fn event(&self, event_type: &str, schema: u32) -> EventSchema
pub fn event(&self, event_type: &str, schema: u32) -> EventSchema
Declares that this domain writes event_type events at version schema, with an
upcast per older version, and which of their fields the vault keeps; see
EventSchema. The domain’s aggregates and listeners use it; other domains’ listeners
get it with Listener::with_domain. Types not declared are at version 1.
§Panics
If event_type is qualified or schema is 0.
Sourcepub fn command(&self, command_type: &str) -> CommandSchema
pub fn command(&self, command_type: &str) -> CommandSchema
Declares which fields of command_type commands the vault keeps (personal,
secret); see CommandSchema. Clients that submit them need the domain:
kernable.with_domain(&domain).
§Panics
If command_type is qualified.
Sourcepub fn query(&self, query_type: &str) -> QuerySchema
pub fn query(&self, query_type: &str) -> QuerySchema
Declares what query_type queries are about (see QuerySchema::target): returns the
QuerySchema to chain target on. A query type (see crate::query) declares it
with target(...) instead. Clients that ask such queries by name need the domain:
kernable.with_domain(&domain).
§Panics
If query_type is qualified.
Sourcepub fn process(&self, name: &str) -> Process
pub fn process(&self, name: &str) -> Process
A business process of this domain named name (fulfilment; qualified
shop.fulfilment): add its start and steps to the crate::process::Process it
returns. An app of the domain registers it with the kernel (crate::Kernable::app).
Example: shop_domain.process("fulfilment").start::<OrderSubmitted>(Start::key("aggregate_id"))....
§Panics
If name is not letters, digits, - and _, or the domain has a process named name
already.
Sourcepub fn read_model(&self, name: &str) -> Listener
pub fn read_model(&self, name: &str) -> Listener
A read model of this domain named name: builds a view from events and answers queries
from it; see Listener. Kept in memory and rebuilt from the first event on every start
(order 0; Listener::store keeps it in a file instead). Run it with
crate::Kernable::listener or in an app. Example:
let carts_readmodel = shop_domain.read_model("carts");.
§Panics
If the domain has a read model or reactor named name already.
Sourcepub fn reactor(&self, name: &str) -> Listener
pub fn reactor(&self, name: &str) -> Listener
A reactor of this domain named name: triggers side effects and follow-up commands; see
Listener. It starts at the newest event when it is new, then resumes after the last
acknowledged event (order 10). A settling submit from its handler waits for the
listeners before it (the read models), not for the reactor itself, which handles one
event at a time. Submit follow-ups with ctx.submit and a fixed ID, so a redelivered
event does not run the command twice; a rejected one parks the event (see
Listener::park_after). Run it with crate::Kernable::listener or in an app.
§Panics
If the domain has a read model or reactor named name already.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Domain
impl Freeze for Domain
impl Move for Domain
impl RefUnwindSafe for Domain
impl Send for Domain
impl Sync for Domain
impl Unpin for Domain
impl UnsafeUnpin for Domain
impl UnwindSafe for Domain
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request