postgres

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

Postgres

Postgres event store is still under development and is missing the following features:

  • Aggregate version consistency validation

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 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) Delete

func (store *EventStore) Delete(ctx context.Context, events ...event.Event) error

Delete deletes the given events from the event store.

func (*EventStore) Find

func (store *EventStore) Find(ctx context.Context, id uuid.UUID) (event.Event, error)

Find fetches the event with the given id from the event store.

func (*EventStore) Insert

func (store *EventStore) Insert(ctx context.Context, events ...event.Event) error

Insert inserts events into the event store.

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.

func (*EventStore) Query

func (store *EventStore) Query(ctx context.Context, query event.Query) (<-chan event.Event, <-chan error, error)

Query queries the event store for events.

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.

Jump to

Keyboard shortcuts

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