Documentation
¶
Index ¶
- Constants
- Variables
- type Backend
- func (b *Backend) Append(reqs ...timebox.AppendRequest) error
- func (b *Backend) Archive(id timebox.AggregateID) error
- func (b *Backend) Close() error
- func (b *Backend) GetAggregateStatus(id timebox.AggregateID) (string, error)
- func (b *Backend) GetAggregateTags(ids ...timebox.AggregateID) (map[timebox.AggregateID][]string, error)
- func (b *Backend) ListAggregatesByStatus(q timebox.StatusQuery) ([]timebox.StatusEntry, error)
- func (b *Backend) LoadEvents(req timebox.LoadEventsRequest) (*timebox.EventsResult, error)
- func (b *Backend) LoadSnapshot(req timebox.LoadSnapshotRequest) (*timebox.SnapshotRecord, error)
- func (b *Backend) NewStore(cfgs ...timebox.Config) (*timebox.Store, error)
- func (b *Backend) SaveSnapshot(req timebox.SnapshotRequest) error
- type Config
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 = 32 )
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 Backend ¶
type Backend struct {
timebox.AlwaysReady
// contains filtered or unexported fields
}
Backend implements timebox.Backend using Postgres
func (*Backend) Append ¶
func (b *Backend) Append(reqs ...timebox.AppendRequest) error
Append appends every request's events if each expected sequence matches
func (*Backend) Archive ¶ added in v0.4.0
func (b *Backend) Archive(id timebox.AggregateID) error
Archive atomically bundles id's snapshot and remaining events into the shared archive queue, then removes id's live records
func (*Backend) GetAggregateStatus ¶
func (b *Backend) GetAggregateStatus(id timebox.AggregateID) (string, error)
GetAggregateStatus gets the current status for an aggregate
func (*Backend) GetAggregateTags ¶ added in v0.5.0
func (b *Backend) GetAggregateTags( ids ...timebox.AggregateID, ) (map[timebox.AggregateID][]string, error)
GetAggregateTags loads the tags each aggregate currently holds, in one query
func (*Backend) ListAggregatesByStatus ¶
func (b *Backend) ListAggregatesByStatus(q timebox.StatusQuery) ([]timebox.StatusEntry, error)
ListAggregatesByStatus lists one page of aggregates matching the query, newest first with ties broken by aggregate key. Through and After both become an exclusive (time, key) upper bound
func (*Backend) LoadEvents ¶
func (b *Backend) LoadEvents(req timebox.LoadEventsRequest) (*timebox.EventsResult, error)
LoadEvents loads events starting at fromSeq
func (*Backend) LoadSnapshot ¶
func (b *Backend) LoadSnapshot(req timebox.LoadSnapshotRequest) (*timebox.SnapshotRecord, error)
LoadSnapshot loads the snapshot and trailing events for an aggregate
func (*Backend) SaveSnapshot ¶
func (b *Backend) SaveSnapshot(req timebox.SnapshotRequest) error
SaveSnapshot saves a snapshot if the provided sequence is not older