Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Persistence
- func (p *Persistence) Append(req timebox.AppendRequest) error
- func (p *Persistence) Close() error
- func (p *Persistence) GetAggregateStatus(id timebox.AggregateID) (string, error)
- func (p *Persistence) ListAggregates(id timebox.AggregateID) ([]timebox.AggregateID, error)
- func (p *Persistence) ListAggregatesByLabel(label, value string) ([]timebox.AggregateID, error)
- func (p *Persistence) ListAggregatesByStatus(status string) ([]timebox.StatusEntry, error)
- func (p *Persistence) ListLabelValues(label string) ([]string, error)
- func (p *Persistence) LoadEvents(req timebox.LoadEventsRequest) (*timebox.EventsResult, error)
- func (p *Persistence) LoadSnapshot(req timebox.LoadSnapshotRequest) (*timebox.SnapshotRecord, error)
- func (p *Persistence) NewStore(cfg timebox.Config) (*timebox.Store, error)
- func (p *Persistence) SaveSnapshot(req timebox.SnapshotRequest) error
Constants ¶
const ( // DefaultURL is the default Postgres connection URL DefaultURL = "postgres://localhost:5432/postgres?sslmode=disable" // DefaultPrefix is the default logical store namespace DefaultPrefix = "timebox" // DefaultMaxConns is the default pgx pool size DefaultMaxConns = 96 )
Variables ¶
var ( // ErrURLRequired indicates URL must be provided ErrURLRequired = errors.New("postgres URL is required") // ErrPrefixRequired indicates Prefix must be provided ErrPrefixRequired = errors.New("prefix is required") // ErrInvalidMaxConns indicates MaxConns must be positive ErrInvalidMaxConns = errors.New("max conns must be positive") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config configures Postgres persistence
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config populated with sensible defaults
type Persistence ¶
type Persistence struct {
timebox.AlwaysReady
Config
// contains filtered or unexported fields
}
Persistence implements timebox.Persistence using Postgres
func NewPersistence ¶
func NewPersistence(cfgs ...Config) (*Persistence, error)
NewPersistence creates Postgres-backed Persistence
func (*Persistence) Append ¶
func (p *Persistence) Append(req timebox.AppendRequest) error
Append appends events if the expected sequence matches
func (*Persistence) Close ¶
func (p *Persistence) Close() error
Close closes the Postgres connection pool
func (*Persistence) GetAggregateStatus ¶
func (p *Persistence) GetAggregateStatus( id timebox.AggregateID, ) (string, error)
GetAggregateStatus gets the current status for an aggregate
func (*Persistence) ListAggregates ¶
func (p *Persistence) ListAggregates( id timebox.AggregateID, ) ([]timebox.AggregateID, error)
ListAggregates lists aggregate IDs matching the given prefix
func (*Persistence) ListAggregatesByLabel ¶
func (p *Persistence) ListAggregatesByLabel( label, value string, ) ([]timebox.AggregateID, error)
ListAggregatesByLabel lists aggregates for a label/value pair
func (*Persistence) ListAggregatesByStatus ¶
func (p *Persistence) ListAggregatesByStatus( status string, ) ([]timebox.StatusEntry, error)
ListAggregatesByStatus lists aggregates for the given status
func (*Persistence) ListLabelValues ¶
func (p *Persistence) ListLabelValues(label string) ([]string, error)
ListLabelValues lists values currently used for a label
func (*Persistence) LoadEvents ¶
func (p *Persistence) LoadEvents( req timebox.LoadEventsRequest, ) (*timebox.EventsResult, error)
LoadEvents loads events starting at fromSeq
func (*Persistence) LoadSnapshot ¶
func (p *Persistence) LoadSnapshot( req timebox.LoadSnapshotRequest, ) (*timebox.SnapshotRecord, error)
LoadSnapshot loads the snapshot and trailing events for an aggregate
func (*Persistence) SaveSnapshot ¶
func (p *Persistence) SaveSnapshot( req timebox.SnapshotRequest, ) error
SaveSnapshot saves a snapshot if the provided sequence is not older