Documentation ¶
Overview ¶
Package bitempura defines a bitemporal key-value database. See bitempura/memory for implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound error is returned when key not found in DB (as of relevant valid and transaction times).
Functions ¶
This section is empty.
Types ¶
type Clock ¶ added in v0.2.3
Clock is an interface for providing the current time for database to use as transaction times.
type DB ¶
type DB interface { // Get data by key (as of optional valid and transaction times). Get(key string, opts ...ReadOpt) (*VersionedKV, error) // List all data (as of optional valid and transaction times). List(opts ...ReadOpt) ([]*VersionedKV, error) // Set stores value (with optional start and end valid time). Set(key string, value Value, opts ...WriteOpt) error // Delete removes value (with optional start and end valid time). Delete(key string, opts ...WriteOpt) error // History returns all versioned key-values for key by descending end transaction time, descending end valid time. History(key string) ([]*VersionedKV, error) }
DB is a key-value database for bitemporal data.
Temporal control options. ReadOpt's: AsOfValidTime, AsOfTransactionTime. WriteOpt's: WithValidTime, WithEndValidTime.
type DefaultClock ¶ added in v0.2.3
type DefaultClock struct{}
DefaultClock is a default clock that implements Now() with time.Now()
func (*DefaultClock) Now ¶ added in v0.2.3
func (c *DefaultClock) Now() time.Time
Now returns time.Now()
type ReadOpt ¶
type ReadOpt func(*ReadOptions)
ReadOpt is an option for database reads
func AsOfTransactionTime ¶
AsOfTransactionTime allows reader to read as of a specified transaction time
func AsOfValidTime ¶
AsOfValidTime allows reader to read as of a specified valid time
type ReadOptions ¶
ReadOptions is a struct for processing ReadOpt's specified on reads.
func ApplyReadOpts ¶ added in v0.2.4
func ApplyReadOpts(opts []ReadOpt) *ReadOptions
ApplyReadOpts applies ReadOpt's to a ReadOptions struct for usage by the DB.
type Value ¶
type Value interface{}
Value is the user-controlled data associated with a key (and valid and transaction time information) in the database.
type VersionedKV ¶
type VersionedKV struct { Key string Value Value TxTimeStart time.Time // inclusive TxTimeEnd *time.Time // exclusive ValidTimeStart time.Time // inclusive ValidTimeEnd *time.Time // exclusive }
VersionedKV is a transaction time and valid time versioned key-value. Transaction and valid time starts are inclusive and ends are exclusive. No two VersionedKVs for the same key can overlap both transaction time and valid time.
func (*VersionedKV) Validate ¶
func (d *VersionedKV) Validate() error
Validate a versioned key-value
type WriteOpt ¶
type WriteOpt func(*WriteOptions)
WriteOpt is an option for database writes
func WithEndValidTime ¶
WithEndValidTime allows writer to configure explicit end valid time. Valid times cannot be set in the future.
func WithValidTime ¶
WithValidTime allows writer to configure explicit valid time. Valid times cannot be set in the future.
type WriteOptions ¶
WriteOptions is a struct for processing WriteOpt's specified on writes.
func ApplyWriteOpts ¶ added in v0.2.4
func ApplyWriteOpts(opts []WriteOpt) *WriteOptions
ApplyWriteOpts applies WriteOpt's to a WriteOptions struct for usage by the DB.
Directories ¶
Path | Synopsis |
---|---|
Package dbtest contains tests for DBs.
|
Package dbtest contains tests for DBs. |
Package memory implements an in-memory, bitemporal key-value database.
|
Package memory implements an in-memory, bitemporal key-value database. |
Package sql implements a SQL-backed, SQL-queryable, bitemporal database.
|
Package sql implements a SQL-backed, SQL-queryable, bitemporal database. |