eventstore

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableNameNotSet = errors.New("table name not set")

ErrTableNameNotSet is the error returned when the table name is not set

Functions

func PositionalPlaceholderDollarSign added in v0.2.0

func PositionalPlaceholderDollarSign(i int) string

Types

type SQLStore

type SQLStore struct {
	DB                      *sql.DB
	TableName               string
	PositionalPlaceholderFn func(int) string
}

SQLStore is an opinionated store that uses a SQL database to store events it mirrors the gosignal.Event struct for fields when storing the events. Only ony table must be used per aggregate type as there is no expectation of columns for the aggregate type.

it should use a schema that matches the following: ```sql

CREATE TABLE events (
	id SERIAL PRIMARY KEY,
	type VARCHAR(255) NOT NULL,
	data BYTEA NOT NULL,
	version INT NOT NULL,
	timestamp INT NOT NULL,
	aggregate_id VARCHAR(255) NOT NULL
);

```

func (SQLStore) Load

func (ss SQLStore) Load(ctx context.Context, aggID string, options sourcing.LoadEventsOptions) (evt []gosignal.Event, err error)

Load loads all events for a given aggregate id TODO: support max version, event types, and to/from timestamps

func (SQLStore) Replace

func (ss SQLStore) Replace(ctx context.Context, id string, version uint64, event gosignal.Event) error

Replace replaces an event with a new version, this mostly exists for legal compliance purposes, your event store should be append-only

func (SQLStore) Store

func (ss SQLStore) Store(ctx context.Context, events []gosignal.Event) error

Store stores a list of events for a given aggregate id

Jump to

Keyboard shortcuts

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