Documentation ¶
Index ¶
- Variables
- type EventStore
- func (s *EventStore) CreateTable(ctx context.Context) error
- func (s *EventStore) DeleteTable(ctx context.Context) error
- func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)
- func (s *EventStore) LoadAll(ctx context.Context) ([]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 IndexInput
- type Option
- type OptionRepo
- type Repo
- func (r *Repo) CreateTable(ctx context.Context) error
- func (r *Repo) DeleteTable(ctx context.Context) error
- func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)
- func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)
- func (r *Repo) FindWithFilter(ctx context.Context, expr string, args ...interface{}) ([]eh.Entity, error)
- func (r *Repo) FindWithFilterUsingIndex(ctx context.Context, indexInput IndexInput, filterQuery string, ...) ([]eh.Entity, error)
- func (r *Repo) Parent() eh.ReadRepo
- func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error
- func (r *Repo) Save(ctx context.Context, entity eh.Entity) error
- func (r *Repo) SetEntityFactory(f func() eh.Entity)
Constants ¶
This section is empty.
Variables ¶
var ErrCouldNotClearDB = errors.New("could not clear database")
ErrCouldNotClearDB is when the database could not be cleared.
var ErrCouldNotDialDB = errors.New("could not dial database")
ErrCouldNotDialDB is when the database could not be dialed.
var ErrCouldNotMarshalEvent = errors.New("could not marshal event")
ErrCouldNotMarshalEvent is when an event could not be marshaled into BSON.
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 ErrModelNotSet = errors.New("model not set")
ErrModelNotSet is when an model factory is not set on the Repo.
Functions ¶
This section is empty.
Types ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore implements an EventStore for DynamoDB.
func NewEventStore ¶
func NewEventStore(tablePrefix string, options ...Option) (*EventStore, error)
NewEventStore creates a new EventStore.
func (*EventStore) CreateTable ¶
func (s *EventStore) CreateTable(ctx context.Context) error
CreateTable creates the table if it is not already existing and correct.
func (*EventStore) DeleteTable ¶
func (s *EventStore) DeleteTable(ctx context.Context) error
DeleteTable deletes the event table.
func (*EventStore) LoadAll ¶
LoadAll will load all the events from the event store (useful to replay events)
func (*EventStore) RenameEvent ¶
RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.
type IndexInput ¶
type IndexInput struct { IndexName string PartitionKey string PartitionKeyValue interface{} SortKey string SortKeyValue interface{} }
IndexInput is all the params we need to filter on an index
type Option ¶
type Option func(*EventStore) error
Option is an option setter used to configure creation.
func WithDynamoDB ¶
WithDBName uses a custom DB name function.
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.
type OptionRepo ¶
Option is an option setter used to configure creation.
func WithRepoDynamoDB ¶
func WithRepoDynamoDB(sess *session.Session) OptionRepo
WithRepoDBName uses a custom DB name function.
func WithRepoEntityFactoryFunc ¶
func WithRepoEntityFactoryFunc(f func() eh.Entity) OptionRepo
func WithRepoPrefixAsTableName ¶
func WithRepoPrefixAsTableName() OptionRepo
WithPrefixAsDBName uses only the prefix as DB name, without namespace support.
func WithRepoTableName ¶
func WithRepoTableName(tableName func(context.Context) string) OptionRepo
WithDBName uses a custom DB name function.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo implements a DynamoDB repository for entities.
func NewRepo ¶
func NewRepo(tablePrefix string, options ...OptionRepo) (*Repo, error)
NewRepo creates a new Repo.
func (*Repo) FindAll ¶
FindAll implements the FindAll method of the eventhorizon.ReadRepo interface.
func (*Repo) FindWithFilter ¶
func (r *Repo) FindWithFilter(ctx context.Context, expr string, args ...interface{}) ([]eh.Entity, error)
FindWithFilter allows to find entities with a filter
func (*Repo) FindWithFilterUsingIndex ¶
func (r *Repo) FindWithFilterUsingIndex(ctx context.Context, indexInput IndexInput, filterQuery string, filterArgs ...interface{}) ([]eh.Entity, error)
FindWithFilterUsingIndex allows to find entities with a filter using an index
func (*Repo) SetEntityFactory ¶
SetEntityFactory sets a factory function that creates concrete entity types.