Documentation ¶
Index ¶
- Variables
- type AggregateEvent
- type AggregateRecord
- type Encoder
- type EventStore
- func (s *EventStore) Clear(ctx context.Context) error
- func (s *EventStore) CreateTables(opts *orm.CreateTableOptions) error
- func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)
- func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error
- func (s *EventStore) Replace(ctx context.Context, event eh.Event) error
- func (s *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrCouldNotClearDB = errors.New("could not clear database")
ErrCouldNotClearDB is when the database could not be cleared.
var ErrCouldNotMarshalEvent = errors.New("could not marshal event")
ErrCouldNotMarshalEvent is when an event could not be marshaled into JSON.
var ErrCouldNotSaveAggregate = errors.New("could not save aggregate")
ErrCouldNotSaveAggregate is when an aggregate could not be saved.
var ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event")
ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into a concrete type.
var ErrVersionConflict = errors.New("Can not create/update aggregate")
ErrConflictVersion is when a version conflict occurs when saving an aggregate.
var NewUUID = uuid.New
NewUUID for mocking in tests
Functions ¶
This section is empty.
Types ¶
type AggregateEvent ¶
type AggregateEvent struct { EventID uuid.UUID `sql:"event_id,type:uuid,pk"` Namespace string `sql:"namespace,type:varchar(250)"` AggregateID uuid.UUID `sql:"aggregate_id,type:uuid"` AggregateType eh.AggregateType `sql:"aggregate_type,type:varchar(250)"` EventType eh.EventType `sql:"event_type,type:varchar(250)"` RawData json.RawMessage `sql:"data,type:jsonb"` Timestamp time.Time `sql:"timestamp"` Version int `sql:"version"` Context map[string]interface{} `sql:"context"` // contains filtered or unexported fields }
type AggregateRecord ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore implements an eh.EventStore for PostgreSQL.
func NewEventStore ¶
func NewEventStore(db *pg.DB, options ...Option) (*EventStore, error)
NewEventStore creates a new EventStore.
func (*EventStore) Clear ¶
func (s *EventStore) Clear(ctx context.Context) error
Clear clears the event storage.
func (*EventStore) CreateTables ¶
func (s *EventStore) CreateTables(opts *orm.CreateTableOptions) error
func (*EventStore) RenameEvent ¶
RenameEvent renames all instances of the event type.
type Option ¶
type Option func(*EventStore) error
Option is an option setter used to configure creation.
func WithEventHandler ¶
func WithEventHandler(h eh.EventHandler) Option
WithEventHandler adds an event handler that will be called when saving events. An example would be to add an event bus to publish events.