redis

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
const DefaultMinIdle = 30 * time.Second

DefaultMinIdle is the idle duration before pending archive work is reclaimed

Variables

View Source
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")
)
View Source
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 Open

func Open(cfgs ...Config) (*Backend, error)

Open opens Redis-backed Backend

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

func (*Backend) Close

func (b *Backend) Close() error

Close closes the Redis client

func (*Backend) ConsumeArchive

func (b *Backend) ConsumeArchive(
	ctx context.Context, handler timebox.ArchiveHandler,
) error

func (*Backend) GetAggregateStatus

func (b *Backend) GetAggregateStatus(
	id timebox.AggregateID,
) (string, error)

func (*Backend) ListAggregates

func (b *Backend) ListAggregates(
	typ timebox.ID,
) ([]timebox.AggregateID, error)

ListAggregates lists aggregate IDs of the given type, or of every type when it is empty

func (*Backend) ListAggregatesByStatus

func (b *Backend) ListAggregatesByStatus(
	q timebox.StatusQuery,
) ([]timebox.StatusEntry, error)

ListAggregatesByStatus lists aggregates matching the query. Type and KeyPrefix narrow by aggregate-id prefix; Through bounds by status time, each via its own native redis op

func (*Backend) ListAggregatesByTag

func (b *Backend) ListAggregatesByTag(
	tag string,
) ([]timebox.AggregateID, error)

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) NewStore

func (b *Backend) NewStore(cfgs ...timebox.Config) (*timebox.Store, error)

NewStore creates a Store using the current Redis Backend

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

func (Config) Validate

func (cfg Config) Validate() error

Validate reports whether the configuration contains invalid values

func (Config) With

func (cfg Config) With(other Config) Config

With overlays the non-zero values from other onto cfg

Jump to

Keyboard shortcuts

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