postgres

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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")
	// 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")
)
View Source
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.

func (*EventStore) Load

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

func (*EventStore) Save

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

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

func NewRepo(host, port, user, password, database string) (*Repo, error)

func NewRepoWithClient added in v0.2.0

func NewRepoWithClient(client *gorm.DB) (*Repo, error)

func (*Repo) Find added in v0.2.0

func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)

func (*Repo) FindAll added in v0.2.0

func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)

func (*Repo) MigrateTables added in v0.2.0

func (r *Repo) MigrateTables(entity interface{}) error

func (*Repo) Parent added in v0.2.0

func (r *Repo) Parent() eh.ReadRepo

func (*Repo) Remove added in v0.2.0

func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error

func (*Repo) Save added in v0.2.0

func (r *Repo) Save(ctx context.Context, entity eh.Entity) error

func (*Repo) SetEntityFactory added in v0.2.0

func (r *Repo) SetEntityFactory(f func() eh.Entity)

SetEntityFactory sets a factory function that creates concrete entity types.

Jump to

Keyboard shortcuts

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