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 ( // DefaultEndpoint is the default Redis/Valkey endpoint DefaultEndpoint = "127.0.0.1:6379" // DefaultPrefix is the default key prefix DefaultPrefix = "timebox" // DefaultDB is the default Redis/Valkey database DefaultDB = 0 )
Variables ¶
var ( // ErrInvalidDB indicates DB is below the allowed range ErrInvalidDB = errors.New("db must be >= 0") // ErrInvalidShard indicates Shard contains disallowed characters ErrInvalidShard = errors.New("shard cannot contain braces or colons") )
var ( // ErrUnexpectedLuaResult indicates a Redis Lua script returned data in an unexpected shape ErrUnexpectedLuaResult = errors.New("unexpected result from Lua script") )
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
timebox.AlwaysReady
// contains filtered or unexported fields
}
Backend implements timebox.Backend using Redis/Valkey
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 ¶
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 loads the current indexed 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 pipelined round trip
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 ID. The type's status set orders members by time-prefixed ID, so each page is one reverse lexical range read
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
type Config ¶
type Config struct {
Addr string
Password string
Prefix string
Shard string
DB int
Publisher timebox.Publisher
}
Config configures a Redis Backend
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config populated with sensible defaults