mongodb

package
v0.15.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 12 Imported by: 8

Documentation

Index

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 implements an eventhorizon.EventStore for MongoDB using a single collection with one document per aggregate/stream which holds its events as values.

func NewEventStore

func NewEventStore(uri, dbName 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, dbName 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() error

Close implements the Close method of the eventhorizon.EventStore interface.

func (*EventStore) Load

func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)

Load implements the Load method of the eventhorizon.EventStore interface.

func (*EventStore) RenameEvent

func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error

RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.

func (*EventStore) Replace

func (s *EventStore) Replace(ctx context.Context, event eh.Event) error

Replace implements the Replace method of the eventhorizon.EventStore interface.

func (*EventStore) Save

func (s *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error

Save implements the Save 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 WithCollectionName added in v0.15.0

func WithCollectionName(eventsColl string) Option

WithCollectionName uses a different event collection than the default "events".

func WithEventHandler added in v0.13.0

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 added in v0.15.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL