snapshots

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLoadingSnapshot = fmt.Errorf("error loading snapshot")

ErrLoadingSnapshot is returned when a snapshot cannot be loaded

View Source
var ErrTableNameNotSet = fmt.Errorf("table name not set")

ErrTableNameNotSet is returned when the table name is not set

Functions

This section is empty.

Types

type SQLStore

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

SQLStore is a store for snapshots that uses a SQL database as its backend. it is highly opinionated and expects there to be columns matching the sourcing.Snapshot struct that means there will be a column for the id, version, and data, and timestamp Further, every aggregate must have its own table as there is no "aggregate type" column it should use a schema that matches the following:

func (SQLStore) Delete

func (ss SQLStore) Delete(ctx context.Context, aggregateID string) error

Delete deletes a snapshot from the store

func (SQLStore) Load

func (ss SQLStore) Load(ctx context.Context, id string) (*sourcing.Snapshot, error)

Load loads a snapshot from the store

func (SQLStore) Store

func (ss SQLStore) Store(ctx context.Context, aggregateID string, snapshot sourcing.Snapshot) error

Store stores a snapshot in the store

type VersionIntervalStrategy

type VersionIntervalStrategy struct {
	EveryNth int
	Store    sourcing.SnapshotStore
}

func (*VersionIntervalStrategy) GetStore

func (versionintervalstrategy *VersionIntervalStrategy) GetStore() sourcing.SnapshotStore

func (*VersionIntervalStrategy) ShouldSnapshot

func (versionintervalstrategy *VersionIntervalStrategy) ShouldSnapshot(snapshot *sourcing.Snapshot, events []gosignal.Event) bool

Jump to

Keyboard shortcuts

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