Sign in

    thy1016/mooncmd/store does not have a README file

    EventStoreError

    pub(all) suberror EventStoreError {
    DuplicateVersion(Int)
    StorageError(String)
    SerializationError(String)
    }

    EventStoreError::to_string

    fn EventStoreError::to_string(self : EventStoreError) -> String

    SnapshotError

    pub(all) suberror SnapshotError {
    StorageError(String)
    SerializationError(String)
    }

    EventStore

    pub(all) struct EventStore[AggregateId, E] {
    append : (EventStore[AggregateId, E], AggregateId, Array[
    EventMessage
    [AggregateId, E]]) -> Unit raise EventStoreError
    load : (EventStore[AggregateId, E], AggregateId, Int) -> Array[
    EventMessage
    [AggregateId, E]] raise EventStoreError
    current_version : (EventStore[AggregateId, E], AggregateId) -> Int raise EventStoreError
    }

    事件存储抽象

    SQLiteEventStore

    pub struct SQLiteEventStore[E] {
    conn :
    Connection

    serialize : (E) -> Bytes
    deserialize : (Bytes) -> E raise
    get_type_name : (E) -> String
    }

    SQLite 实现

    SQLiteEventStore::append

    fn[E] SQLiteEventStore::append(self : SQLiteEventStore[E], aggregate_id : String, events : Array[
    EventMessage
    [String, E]]) -> Unit raise

    SQLiteEventStore::current_version

    fn[E] SQLiteEventStore::current_version(self : SQLiteEventStore[E], aggregate_id : String) -> Int raise

    SQLiteEventStore::init_schema

    fn[E] SQLiteEventStore::init_schema(self : SQLiteEventStore[E]) -> Unit raise

    SQLiteEventStore::load

    fn[E] SQLiteEventStore::load(self : SQLiteEventStore[E], aggregate_id : String, after_version : Int) -> Array[
    EventMessage
    [String, E]] raise

    SQLiteEventStore::new

    fn[E] SQLiteEventStore::new(db_path : String, serialize : (E) -> Bytes, deserialize : (Bytes) -> E raise, get_type_name : (E) -> String) -> SQLiteEventStore[E] raise

    SQLiteEventStore::to_event_store

    fn[E] SQLiteEventStore::to_event_store(self : SQLiteEventStore[E]) -> EventStore[String, E]

    EventStore 记录面适配器:SQLite 实现接入记录型函数面—— 错误穿透不抹平(EventStoreError 变体原样上浮,DuplicateVersion 可分辨)。 聚合 id 域 = String(event_stream.aggregate_id 列 TEXT)。

    Snapshot

    pub struct Snapshot[AggregateId, S] {
    aggregate_id : AggregateId
    state : S
    version : Int
    timestamp : Int64
    }

    快照

    Snapshot::new

    fn[AggregateId, S] Snapshot::new(aggregate_id : AggregateId, state : S, version : Int) -> Snapshot[AggregateId, S]

    SnapshotStore

    pub(all) struct SnapshotStore[AggregateId, S] {
    save : (AggregateId, S, Int, Int64) -> Unit raise SnapshotError
    load : (AggregateId) -> (S, Int)? raise SnapshotError
    }

    快照存储 Trait