Documentation ¶
Index ¶
- type EventStore
- func (s *EventStore) Clear(ctx context.Context) error
- func (s *EventStore) Close() error
- func (s *EventStore) EventsCollectionName() string
- func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)
- func (s *EventStore) LoadFrom(ctx context.Context, id uuid.UUID, version int) ([]eh.Event, error)
- func (s *EventStore) LoadSnapshot(ctx context.Context, id uuid.UUID) (*eh.Snapshot, error)
- func (s *EventStore) Remove(ctx context.Context, id uuid.UUID) 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
- func (s *EventStore) SaveSnapshot(ctx context.Context, id uuid.UUID, snapshot eh.Snapshot) (err error)
- func (s *EventStore) SnapshotsCollectionName() string
- func (s *EventStore) StreamsCollectionName() string
- type Option
- type SnapshotRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore is an eventhorizon.EventStore for MongoDB, using one collection for all events and another to keep track of all aggregates/streams. It also keeps track of the global position of events, stored as metadata.
func NewEventStore ¶
func NewEventStore(uri, dbName string, options ...Option) (*EventStore, error)
NewEventStore creates a new EventStore with a MongoDB URI: `mongodb://hostname`.
func NewEventStoreWithClient ¶
func NewEventStoreWithClient(client *mongo.Client, dbName string, options ...Option) (*EventStore, error)
NewEventStoreWithClient creates a new EventStore with a client.
func NewMongoDBEventStore ¶
func NewMongoDBEventStore(db eh.MongoDB, options ...Option) (*EventStore, error)
NewMongoDBEventStore creates a new EventStore using the eventhorizon.MongoDB interface.
func (*EventStore) Clear ¶
func (s *EventStore) Clear(ctx context.Context) error
Clear implements the Clear method of the eventhorizon.EventStoreMaintenance interface.
func (*EventStore) Close ¶
func (s *EventStore) Close() error
Close implements the Close method of the eventhorizon.EventStore interface.
func (*EventStore) EventsCollectionName ¶
func (s *EventStore) EventsCollectionName() string
EventsCollectionName returns the name of the events collection.
func (*EventStore) LoadFrom ¶
LoadFrom implements LoadFrom method of the eventhorizon.SnapshotStore interface.
func (*EventStore) LoadSnapshot ¶
func (*EventStore) Remove ¶ added in v0.20.0
Clear implements the Clear method of the eventhorizon.EventStoreMaintenance interface.
func (*EventStore) RenameEvent ¶
RenameEvent implements the RenameEvent method of the eventhorizon.EventStoreMaintenance interface.
func (*EventStore) Replace ¶
Replace implements the Replace method of the eventhorizon.EventStoreMaintenance interface.
func (*EventStore) SaveSnapshot ¶
func (*EventStore) SnapshotsCollectionName ¶
func (s *EventStore) SnapshotsCollectionName() string
SnapshotsCollectionName returns the name of the snapshots collection.
func (*EventStore) StreamsCollectionName ¶
func (s *EventStore) StreamsCollectionName() string
StreamsCollectionName returns the name of the streams collection.
type Option ¶
type Option func(*EventStore) error
Option is an option setter used to configure creation.
func WithCollectionNames ¶
WithCollectionNames uses different collections from the default "events" and "streams" collections. Will return an error if provided parameters are equal.
func WithEventHandler ¶
func WithEventHandler(h eh.EventHandler) Option
WithEventHandler adds an event handler that will be called after saving events. An example would be to add an event bus to publish events.
func WithEventHandlerInTX ¶
func WithEventHandlerInTX(h eh.EventHandler) Option
WithEventHandlerInTX adds an event handler that will be called during saving of events. An example would be to add an outbox to further process events. For an outbox to be atomic it needs to use the same transaction as the save operation, which is passed down using the context.
func WithSnapshotCollectionName ¶
WithSnapshotCollectionName uses different collections from the default "snapshots" collections.