thy1016/mooncmd/aggregate does not have a README file
pub trait AggregateId {
fn to_string(Self) -> String
fn from_string(s : String) -> Result[Self, AggregateError]
fn eq(self : Self, other : Self) -> Bool
}impl AggregateId for Intfn eq(self : Int, other : Int) -> Boolfn to_string(self : Int) -> Stringimpl AggregateId for Stringfn eq(self : String, other : String) -> Boolfn to_string(self : String) -> Stringpub struct AggUUID {
value : String
}impl AggregateId for AggUUIDpub struct AggregateRoot[AggregateId, S, C, E] {
handler : (S, C) -> Result[Array[E], CommandError]
applier : EventApplier[S, E]
empty_state : S
state : AggregateState[AggregateId, S, E]
id : AggregateId
}fn[AggregateId, S, C, E] AggregateRoot::commit(self : AggregateRoot[AggregateId, S, C, E]) -> AggregateRoot[AggregateId, S, C, E]fn[AggregateId, S, C, E] AggregateRoot::current_state(self : AggregateRoot[AggregateId, S, C, E]) -> Sfn[AggregateId, S, C, E] AggregateRoot::exec(self : AggregateRoot[AggregateId, S, C, E], cmd : C) -> AggregateRoot[AggregateId, S, C, E] raise CommandErrorfn[AggregateId, S, C, E] AggregateRoot::exec_with_effect(self : AggregateRoot[AggregateId, S, C, E], cmd : C, machine : RetryMachine, hooks : RetryHooks, wait : (Int64) -> Unit) -> AggregateRoot[AggregateId, S, C, E] raise CommandErrorfn[AggregateId, S, C, E] AggregateRoot::execute(self : AggregateRoot[AggregateId, S, C, E], cmd : CommandMessage[C]) -> Result[AggregateRoot[AggregateId, S, C, E], CommandError]fn[AggregateId, S, C, E] AggregateRoot::from_events(id : AggregateId, events : Array[EventMessage[AggregateId, E]], handler : (S, C) -> Result[Array[E], CommandError], applier : EventApplier[S, E], empty_state : S) -> AggregateRoot[AggregateId, S, C, E]fn[AggregateId, S, C, E] AggregateRoot::from_snapshot(id : AggregateId, empty_state : S, base_state : S, base_version : Int, events : Array[EventMessage[AggregateId, E]], handler : (S, C) -> Result[Array[E], CommandError], applier : EventApplier[S, E]) -> AggregateRoot[AggregateId, S, C, E]fn[AggregateId, S, C, E] AggregateRoot::new(id : AggregateId, handler : (S, C) -> Result[Array[E], CommandError], applier : EventApplier[S, E], empty_state : S) -> AggregateRoot[AggregateId, S, C, E]fn[AggregateId, S, C, E] AggregateRoot::to_snapshot(self : AggregateRoot[AggregateId, S, C, E]) -> Snapshot[AggregateId, S]fn[AggregateId, S, C, E] AggregateRoot::uncommitted_events(self : AggregateRoot[AggregateId, S, C, E]) -> Array[EventMessage[AggregateId, E]]pub struct AggregateState[AggregateId, S, E] {
state : S
version : Int
uncommitted_events : Array[EventMessage[AggregateId, E]]
}pub(all) enum EffectErrorKind {
Duplicate
Validation
Storage
Other
}pub(all) struct RetryMachine {
default_action : (EffectErrorKind) -> RetryAction
decide : (Int, Int, EffectErrorKind) -> RetryVerdict
}Install
Download zipCommand-side event sourcing kernel for MoonBit: pure command handlers, auto-wrapped EventMessage metadata (correlation/causation), optimistic concurrency with duplicate-version rejection, SQLite event store, projections and snapshots.