tvks

package module
v0.0.0-...-61c0dfe Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 5 Imported by: 0

README

tvks

Documentation

Overview

Package tvks provides a simple-to-use immutable time-series blob database

Index

Constants

View Source
const (
	TvksDuplicateKey = iota
	TvksItemExists
	TvksItemNotFound
	TvksInternalError
	TvksOk
)

Result codes that are returned in an Error as-well-as QueryData

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db struct {
	// contains filtered or unexported fields
}

Actual database object that holds records

func Open

func Open(path string, groups []string) (*Db, error)

Open a database and give a list of groups that are expected to exist there. If the group does not exist yet, they will be made

func (*Db) Close

func (tdb *Db) Close()

Close the database

func (*Db) ExecuteQuery

func (tdb *Db) ExecuteQuery(query *Query) (*QueryResult, *Error)

Submit a retrieval query to the database. Queries do no modify the data

func (*Db) Store

func (tdb *Db) Store(group *string, value *KeyValue) *Error

Store a record in the database unser a its correlated group

type Error

type Error struct {
	Id    int
	Value error
}

Error that may occur when interacting with tvks

func (*Error) String

func (e *Error) String() string

type KeyValue

type KeyValue struct {
	Key   time.Time // Time key
	Value []byte    // Nebulous data
	Meta  []byte    // Nebulous meta data
}

Thg base key/ value structure that is used to represent records

type Query

type Query struct {
	RefId  uint64      // Reference ID that query builder can use to match query with result
	Groups *[]string   // List of groups to run the query against
	Range  *QueryRange // Inclusive time range for query
}

Query into the Db

func QueryAfter

func QueryAfter(
	ref uint64,
	start time.Time,
	groups *[]string) *Query

func QueryAt

func QueryAt(
	ref uint64,
	start time.Time,
	groups *[]string) *Query

func QueryBefore

func QueryBefore(
	ref uint64,
	start time.Time,
	groups *[]string) *Query

func QueryBetween

func QueryBetween(
	ref uint64,
	start time.Time,
	end time.Time,
	groups *[]string) *Query

type QueryData

type QueryData struct {
	ResultCode int
	Values     []*KeyValue
}

Resulting data from query

type QueryRange

type QueryRange struct {
	Start *time.Time
	End   *time.Time
}

Specify a time range for a query

type QueryResult

type QueryResult struct {
	RefId  uint64               // User-defined id to match result to query
	Result map[string]QueryData // Results per-group sekectuib
}

type TvksRead

type TvksRead interface {
	ExecuteQuery(query *Query) (*QueryResult, *Error)
}

type TvksReadWrite

type TvksReadWrite interface {
	TvksRead
	TvksWrite
}

type TvksWrite

type TvksWrite interface {
	Store(group *string, data *KeyValue) *Error
}

Jump to

Keyboard shortcuts

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