Documentation ¶
Index ¶
- type AggregateLoaderError
- type AggregateNotFoundError
- type AggregateRepository
- func (ar *AggregateRepository) AddProjector(event eventsourcing.Event, projector eventsourcing.Projector)
- func (ar *AggregateRepository) Load(ctx context.Context, aggregateID uint64) (eventsourcing.Aggregate, error)
- func (ar *AggregateRepository) NewEmptyAggregate() eventsourcing.Aggregate
- func (ar *AggregateRepository) Save(ctx context.Context, aggregate eventsourcing.Aggregate) error
- type AggregateRepositoryOption
- type AggregateSaverError
- type ApplyEventError
- type EventMarshalError
- type EventModel
- type EventProjectorError
- type EventPublishError
- type EventStore
- type EventUnmarshalError
- type EventVersionConflictError
- type LoadEventError
- type TransactionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateLoaderError ¶
type AggregateLoaderError struct {
// contains filtered or unexported fields
}
func (AggregateLoaderError) Error ¶
func (ale AggregateLoaderError) Error() string
func (AggregateLoaderError) Unwrap ¶
func (ale AggregateLoaderError) Unwrap() error
type AggregateNotFoundError ¶
type AggregateNotFoundError struct {
// contains filtered or unexported fields
}
func (AggregateNotFoundError) Error ¶
func (anfe AggregateNotFoundError) Error() string
type AggregateRepository ¶
type AggregateRepository struct {
// contains filtered or unexported fields
}
func NewAggregateRepository ¶
func NewAggregateRepository( aggregate eventsourcing.Aggregate, db *gorm.DB, options ...AggregateRepositoryOption, ) *AggregateRepository
func (*AggregateRepository) AddProjector ¶
func (ar *AggregateRepository) AddProjector(event eventsourcing.Event, projector eventsourcing.Projector)
AddProjector add a projector to repository.
func (*AggregateRepository) Load ¶
func (ar *AggregateRepository) Load( ctx context.Context, aggregateID uint64, ) (eventsourcing.Aggregate, error)
Load loads a aggregate by aggregateID.
If a AggregateLoader is provided, it loads from the AggregateLoader, otherwise it loads from the event store.
func (*AggregateRepository) NewEmptyAggregate ¶
func (ar *AggregateRepository) NewEmptyAggregate() eventsourcing.Aggregate
func (*AggregateRepository) Save ¶
func (ar *AggregateRepository) Save(ctx context.Context, aggregate eventsourcing.Aggregate) error
Save saves the aggregate.
After appending the uncommitted events to event store, it run projectors. If a AggregateSaver is provided, it also save the aggregate with the AggregateSaver. If any errors happened, all changes will be rollbacked.
type AggregateRepositoryOption ¶
type AggregateRepositoryOption func(*AggregateRepository)
func WithAggregateLoader ¶
func WithAggregateLoader(aggregateLoader eventsourcing.AggregateLoader) AggregateRepositoryOption
WithAggregateLoader configure a AggregateLoader for the repository.
func WithAggregateSaver ¶
func WithAggregateSaver(aggregateSaver eventsourcing.AggregateSaver) AggregateRepositoryOption
WithAggregateSaver configure a AggregateSaver for the repository.
type AggregateSaverError ¶
type AggregateSaverError struct {
// contains filtered or unexported fields
}
func (AggregateSaverError) Error ¶
func (ale AggregateSaverError) Error() string
type ApplyEventError ¶
type ApplyEventError struct {
// contains filtered or unexported fields
}
func (ApplyEventError) Error ¶
func (aee ApplyEventError) Error() string
type EventMarshalError ¶
type EventMarshalError struct {
// contains filtered or unexported fields
}
func (EventMarshalError) Error ¶
func (eue EventMarshalError) Error() string
type EventModel ¶
type EventModel struct { CreatedAt time.Time `gorm:"column:created_at"` AggregateID uint64 `gorm:"column:aggregate_id"` // foreign key to the Transaction table ParentID uint64 `gorm:"column:parent_id"` // parent aggregate id EventType string `gorm:"column:event_type"` // event EventType Payload string `gorm:"column:payload"` // event payload Version int `gorm:"column:version"` // event version number, used for ordering events }
func NewEventModelFromEvent ¶
func NewEventModelFromEvent(event eventsourcing.Event) (*EventModel, error)
NewEventModelFromEvent converts a event to EventModel.
func (*EventModel) ToEvent ¶
func (ev *EventModel) ToEvent( reg *eventsourcing.EventRegistry, ) (eventsourcing.Event, error)
ToEvent converts a EventModel to Event.
type EventProjectorError ¶
type EventProjectorError struct {
// contains filtered or unexported fields
}
func (EventProjectorError) Error ¶
func (epe EventProjectorError) Error() string
type EventPublishError ¶
type EventPublishError struct {
// contains filtered or unexported fields
}
func (EventPublishError) Error ¶
func (epe EventPublishError) Error() string
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
func NewEventStore ¶
func NewEventStore( eventTable string, er *eventsourcing.EventRegistry, db *gorm.DB, ) *EventStore
func (*EventStore) Append ¶
func (es *EventStore) Append(ctx context.Context, events []eventsourcing.Event) error
func (*EventStore) Load ¶
func (es *EventStore) Load( ctx context.Context, aggregateID uint64, startVersion int, ) ([]eventsourcing.Event, error)
type EventUnmarshalError ¶
type EventUnmarshalError struct {
// contains filtered or unexported fields
}
func (EventUnmarshalError) Error ¶
func (eue EventUnmarshalError) Error() string
type EventVersionConflictError ¶
type EventVersionConflictError struct {
// contains filtered or unexported fields
}
func (*EventVersionConflictError) Error ¶
func (cee *EventVersionConflictError) Error() string
type LoadEventError ¶
type LoadEventError struct {
// contains filtered or unexported fields
}
func (LoadEventError) Error ¶
func (lee LoadEventError) Error() string
type TransactionError ¶
type TransactionError struct {
// contains filtered or unexported fields
}
func (TransactionError) Error ¶
func (te TransactionError) Error() string
func (TransactionError) Unwrap ¶
func (te TransactionError) Unwrap() error