eventsourcing

Types

pub type Aggregate(entity, command, event, error) {
  Aggregate(
    entity: entity,
    handle: Handle(entity, command, event, error),
    apply: Apply(entity, event),
  )
}

Constructors

  • Aggregate(
      entity: entity,
      handle: Handle(entity, command, event, error),
      apply: Apply(entity, event),
    )
pub type AggregateContext(entity, command, event, error) {
  AggregateContext(
    aggregate_id: AggregateId,
    aggregate: Aggregate(entity, command, event, error),
    sequence: Int,
  )
}

Constructors

  • AggregateContext(
      aggregate_id: AggregateId,
      aggregate: Aggregate(entity, command, event, error),
      sequence: Int,
    )
pub type EventEnvelop(event) {
  MemoryStoreEventEnvelop(
    aggregate_id: AggregateId,
    sequence: Int,
    payload: event,
  )
  SerializedEventEnvelop(
    aggregate_id: AggregateId,
    sequence: Int,
    payload: event,
    event_type: String,
    event_version: String,
    aggregate_type: String,
  )
}

Constructors

  • MemoryStoreEventEnvelop(
      aggregate_id: AggregateId,
      sequence: Int,
      payload: event,
    )
  • SerializedEventEnvelop(
      aggregate_id: AggregateId,
      sequence: Int,
      payload: event,
      event_type: String,
      event_version: String,
      aggregate_type: String,
    )
pub type EventSourcing(
  eventstore,
  entity,
  command,
  event,
  error,
  aggregatecontext,
) {
  EventSourcing(
    event_store: EventStore(
      eventstore,
      entity,
      command,
      event,
      error,
    ),
    queries: List(Query(event)),
  )
}

Constructors

  • EventSourcing(
      event_store: EventStore(
        eventstore,
        entity,
        command,
        event,
        error,
      ),
      queries: List(Query(event)),
    )
pub type EventStore(eventstore, entity, command, event, error) {
  EventStore(
    eventstore: eventstore,
    load_aggregate: fn(eventstore, AggregateId) ->
      AggregateContext(entity, command, event, error),
    commit: fn(
      eventstore,
      AggregateContext(entity, command, event, error),
      List(event),
    ) ->
      List(EventEnvelop(event)),
  )
}

Constructors

  • EventStore(
      eventstore: eventstore,
      load_aggregate: fn(eventstore, AggregateId) ->
        AggregateContext(entity, command, event, error),
      commit: fn(
        eventstore,
        AggregateContext(entity, command, event, error),
        List(event),
      ) ->
        List(EventEnvelop(event)),
    )

Functions

pub fn execute(
  event_sourcing: EventSourcing(a, b, c, d, e, f),
  aggregate_id aggregate_id: String,
  command command: c,
) -> Result(Nil, e)
pub fn new(
  event_store: EventStore(a, b, c, d, e),
  queries: List(fn(String, List(EventEnvelop(d))) -> Nil),
) -> EventSourcing(a, b, c, d, e, f)
Search Document