Documentation ¶
Index ¶
- type EventStore
- func (store *EventStore) Connect(ctx context.Context) error
- func (store *EventStore) Delete(ctx context.Context, events ...event.Event) error
- func (store *EventStore) Find(ctx context.Context, id uuid.UUID) (event.Event, error)
- func (store *EventStore) Insert(ctx context.Context, events ...event.Event) error
- func (store *EventStore) Pool() *pgxpool.Pool
- func (store *EventStore) Query(ctx context.Context, query event.Query) (<-chan event.Event, <-chan error, error)
- type EventStoreOption
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 a PostgreSQL event store.
func NewEventStore ¶
func NewEventStore(enc codec.Encoding, opts ...EventStoreOption) *EventStore
NewEventStore returns a new PostgreSQL event store. If not otherwise specified using the URL() option, os.Getenv("POSTGRES_EVENTSTORE") is used as the connection string.
func (*EventStore) Connect ¶
func (store *EventStore) Connect(ctx context.Context) error
Connect connects to the PostgreSQL server. Connect is automatically called from the Insert, Find, Query, and Delete methods if not called explicitly.
func (*EventStore) Pool ¶
func (store *EventStore) Pool() *pgxpool.Pool
Pool returns the underlying Postgres connection pool. Pool must only be called AFTER the connection to Postgres has been established. Otherwise the returned Pool will be nil. It is not thread-safe to call Pool concurrently with Connect.
type EventStoreOption ¶
type EventStoreOption func(*EventStore)
EventStoreOption is an optionn for the PostgreSQL event store.
func Database ¶
func Database(name string) EventStoreOption
Database returns an EventStoreOption that configures the used database. Defaults to "goes".
func Table ¶
func Table(name string) EventStoreOption
Table returns an EventStoreOption that configures the used table for events. Defaults to "events".
func URL ¶
func URL(url string) EventStoreOption
URL returns an EventStoreOption that specifies the connection string to the PostgreSQL server.