Skip to main content

DeclaredEvent

Trait DeclaredEvent 

Source
pub trait DeclaredEvent: Serialize {
    const NAME: &'static str;
    const VERSION: i32;
    const AGGREGATE: &'static str;

    // Provided methods
    fn record(&self, aggregate_id: &str, ctx: &WriteCtx) -> OutboxRecord { ... }
    fn record_for(
        &self,
        aggregate_id: &str,
        company_id: Uuid,
        ctx: &WriteCtx,
    ) -> OutboxRecord { ... }
}
Expand description

A fact the module declares it publishes (events: in a schema file), as the generated typed struct of its payload.

The schema generator implements this for every declared event, in the module’s domain::event::declared. An event with an on: trigger is staged by the generated write hooks; one without is staged by hand code, which builds its row with record and stages it in its own transaction (backbone_outbox::outbox::stage) or on the write’s (WriteCtx::stage).

Required Associated Constants§

Source

const NAME: &'static str

The event type name the outbox row carries (TicketOpened).

Source

const VERSION: i32

The declared schema version of the payload.

Source

const AGGREGATE: &'static str

The aggregate the event belongs to (Ticket), or "" when the declaration names none.

Provided Methods§

Source

fn record(&self, aggregate_id: &str, ctx: &WriteCtx) -> OutboxRecord

The outbox row of this event for aggregate aggregate_id, under the company of ctx (or the nil uuid when the request has none). A fresh event id, now as the time it occurred, the declared version, and the payload serialized as written.

Source

fn record_for( &self, aggregate_id: &str, company_id: Uuid, ctx: &WriteCtx, ) -> OutboxRecord

record for an aggregate that carries its own company.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§