Documentation
¶
Index ¶
- Variables
- type EventStore
- type Option
- type Repo
- 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) MigrateTables(entity interface{}) 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 ( // 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") // ErrModelNotSet is when an model factory is not set on the Repo. ErrModelNotSet = errors.New("model not set") // ErrInvalidQuery is when a query was not returned from the callback to FindCustom. ErrInvalidQuery = errors.New("invalid query") )
var (
ErrEventstoreMigration = errors.New("could not create event store tables")
)
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(host, port, user, password, database string, options ...Option) (*EventStore, error)
NewEventStore creates a new EventStore...
func NewEventStoreWithClient ¶
func NewEventStoreWithClient(client *gorm.DB, options ...Option) (*EventStore, error)
NewEventStoreWithClient creates a new EventStore with a client.
func (*EventStore) Close ¶
func (e *EventStore) Close(ctx context.Context) error
Close closes the database client. TODO: maybe should not be closed.
type Option ¶
type Option func(*EventStore) error
Option is an option setter used to configure creation.
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 Repo ¶ added in v0.2.0
type Repo struct {
// contains filtered or unexported fields
}
Repo implements a PostgreSQL repo for entities.
func (*Repo) MigrateTables ¶ added in v0.2.0
func (*Repo) SetEntityFactory ¶ added in v0.2.0
SetEntityFactory sets a factory function that creates concrete entity types.