Documentation ¶
Index ¶
- Variables
- type EventStore
- func (s *EventStore) Clear(ctx context.Context) error
- func (s *EventStore) Close(ctx context.Context)
- 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 ¶
View Source
var ( // ErrCouldNotDialDB is when the database could not be dialed. ErrCouldNotDialDB = errors.New("could not dial database") // ErrNoDBClient is when no database client is set. ErrNoDBClient = errors.New("no database client") // ErrCouldNotClearDB is when the database could not be cleared. ErrCouldNotClearDB = errors.New("could not clear database") // ErrCouldNotMarshalEvent is when an event could not be marshaled into BSON. ErrCouldNotMarshalEvent = errors.New("could not marshal event") // ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into a concrete type. ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event") // ErrCouldNotLoadAggregate is when an aggregate could not be loaded. ErrCouldNotLoadAggregate = errors.New("could not load aggregate") // ErrCouldNotSaveAggregate is when an aggregate could not be saved. ErrCouldNotSaveAggregate = errors.New("could not save aggregate") )
Functions ¶
This section is empty.
Types ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore implements an EventStore for MongoDB.
func NewEventStore ¶
func NewEventStore(uri, dbPrefix string, options ...Option) (*EventStore, error)
NewEventStore creates a new EventStore with a MongoDB URI: `mongodb://hostname`.
func NewEventStoreWithClient ¶ added in v0.6.0
func NewEventStoreWithClient(client *mongo.Client, dbPrefix string, options ...Option) (*EventStore, error)
NewEventStoreWithClient creates a new EventStore with a client.
func (*EventStore) Clear ¶
func (s *EventStore) Clear(ctx context.Context) error
Clear clears the event storage.
func (*EventStore) Close ¶
func (s *EventStore) Close(ctx context.Context)
Close closes the database client.
func (*EventStore) RenameEvent ¶
RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.
type Option ¶ added in v0.7.0
type Option func(*EventStore) error
Option is an option setter used to configure creation.
func WithDBName ¶ added in v0.7.0
WithDBName uses a custom DB name function.
func WithPrefixAsDBName ¶ added in v0.7.0
func WithPrefixAsDBName() Option
WithPrefixAsDBName uses only the prefix as DB name, without namespace support.
Click to show internal directories.
Click to hide internal directories.