mongodb

package module
v0.0.0-...-7c007b0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Build Status codecov GoDoc Go Report Card

eh-mongodb

This package is based on the default mongo-driver in EventHorizon. Mongo has a document limit of 16MB which can easily be reached in big projects, resulting in aggregates with many events not being saved.

The default mongo-driver in EventHorizon stores an aggregate with its events in one single document, increasing the size of the document on each event. This driver creates a new document per event, preventing documents from growing and reaching the limit mentioned above.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotClearDB = errors.New("could not clear database")

ErrCouldNotClearDB is when the database could not be cleared.

View Source
var ErrCouldNotDialDB = errors.New("could not dial database")

ErrCouldNotDialDB is when the database could not be dialed.

View Source
var ErrCouldNotLoadAggregate = errors.New("could not load aggregate")

ErrCouldNotLoadAggregate is when an aggregate could not be loaded.

View Source
var ErrCouldNotMarshalEvent = errors.New("could not marshal event")

ErrCouldNotMarshalEvent is when an event could not be marshaled into BSON.

View Source
var ErrCouldNotSaveAggregate = errors.New("could not save aggregate")

ErrCouldNotSaveAggregate is when an aggregate could not be saved.

View Source
var ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event")

ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into a concrete type.

View Source
var ErrNoDBClient = errors.New("no database client")

ErrNoDBClient is when no database client is set.

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) (*EventStore, error)

NewEventStore creates a new EventStore with a MongoDB URI: `mongodb://hostname`.

func NewEventStoreWithClient

func NewEventStoreWithClient(client *mongo.Client, dbPrefix string) (*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) 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.

Jump to

Keyboard shortcuts

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