Expand description
Derives emit trait impls and descriptions only; behaviour lives in the libraries.
Attribute Macros§
- contract
- Each
async fnreturns a boxed future so the trait works asdyn. - every
- Interval as
30s,15m,1h,1d;each = queryruns it per listed record, one job each. Or a time on a zone’s clock:daily_at = "03:00", zone = "Europe/Istanbul", and withweekly_on = "monday"on that day only. - feature
- Written
#[sofie::feature(FLAG)]: a barefeatureis Rust’s own crate attribute. - gateway
- Calls run in
<vendor>.<method>spans; seesofie::client. - job
- Read by
sofie gen, which registers the job with the worker. - on
- Takes no arguments: naming the event again could only disagree with the argument’s type.
- span
- Its arguments are never recorded.
- task
- Read by
sofie gen, which registers the task as<module>.<function>. - test_
app - One database per test; the crate’s wiring must export
MODULES,appandworker.
Derive Macros§
- Aggregate
#[owner]marks theId<…>field naming the owner; on the struct, a record that is its own owner, or with(through = parent)one owned by its parent’s owner.#[aggregate(behaviors(Slugged(from = name)))]adds behaviors toVersionedandTimestamps. Field constraints are those of#[derive(Input)]. A#[sensitive]field shows as***inDebugand logs; it and one of a sensitive type stay out of JSON and search.- Child
- Needs an
id: Id<Self>field; stored in its own table beside the aggregate’s. - Config
- Read from its module’s
<MODULE>_<FIELD>keys; a field of another struct deriving it reads<MODULE>_<FIELD>_*. - Enum
#[to(…)]lists a variant’s transitions.- Event
- Fixture
- Expands to nothing unless sofie’s
fixturesfeature is on. - Input
#[min(n)]/#[max(n)]bound text characters or a number’s value;#[length(min, max)],#[range(min, max)],#[required](not blank) and#[unique](held by the database only).#[input(from = Order)]inheritsOrder’s field constraints,#[unconstrained]drops them;#[input(validate)]runsValidateafter them.- Read
Model #[read(from = Aggregate)];#[read(via = Base::COLUMN, field = Other::COLUMN)]reads a column of the record the base’s id column names. A field reading a sensitive one needs#[sensitive].- Value
#[sensitive]masks it inDebug. As a handler’s input it is read from the body field named after the type:cancel(order: Order, cancel_reason: CancelReason)takes{ "cancel_reason": … }, andOption<CancelReason>takes it or nothing.