tsdb

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 6 Imported by: 0

README

tsdb

codecov

一个简易TSDB,个人习作。 结构基本参考了 InfluxDB 的 Cache

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPointMissingTag = errors.New("tsdb: point missing tag")
	ErrDBClosed        = errors.New("tsdb: db is closed")
)

Functions

This section is empty.

Types

type Point

type Point[T any] struct {
	// contains filtered or unexported fields
}

Point 代表时序数据的一个点,只读的

func NewPoint

func NewPoint[T any](tags []Tag, t time.Time, field T) Point[T]

NewPoint New 一个 point ,tag key 不能重复,重复时以后者为准

func (Point[T]) Series

func (p Point[T]) Series() string

type TSDB

type TSDB[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](retentionPolicy time.Duration) *TSDB[T]

func (*TSDB[T]) QueryPoints

func (db *TSDB[T]) QueryPoints(tags []Tag, min, max time.Time) map[string][]Value[T]

QueryPoints 查询数据点

func (*TSDB[T]) Stop

func (db *TSDB[T]) Stop()

func (*TSDB[T]) WritePoints

func (db *TSDB[T]) WritePoints(points []Point[T]) error

WritePoints 写入数据点

type Tag

type Tag struct {
	Key   string
	Value string
}

func (Tag) String

func (t Tag) String() string

type Value

type Value[T any] struct {
	UnixNano int64
	V        T
}

Value 保存时间和值

Jump to

Keyboard shortcuts

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