eventstore

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 6 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

This section is empty.

Types

type SQLStore

type SQLStore struct {
	DB        *sql.DB
	TableName 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 TIMESTAMP WITH TIME ZONE 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

func (SQLStore) Replace

func (ss SQLStore) Replace(ctx context.Context, id string, version uint, 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