history

package
v0.0.0-test-multiarch Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package history provides a store for historical records. This package contains the interfaces and general types, see various foostore packages for actual store implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	ID         string
	CreateTime time.Time
	Payload    []byte
}

Record is a payload as it was at a point in time.

func (Record) IsZero

func (r Record) IsZero() bool

IsZero returns whether r is equivalent to Record{}, the zero record.

type Slice

type Slice interface {
	// Slice creates a new slice including records >= from and < to.
	// If from is zero then it is treated as the first record available,
	// if to is zero then it is the record immediately after the last record,
	// just like with go slices.
	// The record should have either ID and/or CreateTime set.
	Slice(from, to Record) Slice
	// Read reads records from the slice starting at the first record available, ending when into is full (according to len).
	// Read returns the number of records actually read.
	// The first record read will be places into index 0, the second into index 1, and so on.
	Read(ctx context.Context, into []Record) (int, error)
	// Len returns the number of records this slice represents.
	Len(ctx context.Context) (int, error)
}

Slice describes a read-only ordered segment of a Store.

type Store

type Store interface {
	// Append adds the given payload to the store, returning the Record as recorded.
	// The context can be used to abort the append operation if needed.
	Append(ctx context.Context, payload []byte) (Record, error)
	Slice
}

Store defines an append-only collection of ordered records. The store can be sliced, like a go slice, to query for a range of records which can then be read.

Directories

Path Synopsis
Package boltstore provides an implementation of history.Store with records stored in a bolthold database.
Package boltstore provides an implementation of history.Store with records stored in a bolthold database.
Package memstore provides an implementation of history.Store with records stored in memory.
Package memstore provides an implementation of history.Store with records stored in memory.
Package pgxstore provides an implementation of history.Store backed by a Postgres database.
Package pgxstore provides an implementation of history.Store backed by a Postgres database.

Jump to

Keyboard shortcuts

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