tsdb

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockDataSeparator sets a separator for block datavalue
	BlockDataSeparator = "|"
)

Variables

This section is empty.

Functions

func GetNormalizedTimeCalc

func GetNormalizedTimeCalc() int64

GetNormalizedTime returns the UnixNano time as normalized time.

func GetTimeStampCalc

func GetTimeStampCalc() string

GetTimeStamp returns the timestamp

Types

type BQRoute

type BQRoute struct {
	DomainIP string
	Method   string
}

BQRoute is a struct which contains a Domain IP and it's subsequent method

type BRQuerier

type BRQuerier struct {
	// As of now, ServiceName can be one of these: ping, food-ping, jitter, req-res-delay
	ServiceName string

	// Route contains a unique identifier and it's method for uniquely
	// identifying the particular time-series
	Route BQRoute

	// Suffix is used for cases involving additional information for identifying the
	// db. Example: req-res-delay-monitoring contains `_delay`, `_length`, `_status`. Hence,
	// the suffix is the respective word excluding `_`
	Suffix string

	// Connection helps the querier to respond to the requests directly without
	// worrying about the goroutines.
	Connection *websocket.Conn

	// Complete address of the persistent blocks.
	Address string
	// contains filtered or unexported fields
}

BRQuerier is a querier for querying over the time-series stored in the tsdb

func (*BRQuerier) FetchAllSeriesStringified

func (bq *BRQuerier) FetchAllSeriesStringified() string

FetchAllSeriesStringified returns all the series from the particular chunk. It does not do any processing, rather just a plain simple fetch and return the fetched samples. It is go-routine safe and respond to multiple same series requests.

func (*BRQuerier) GetAddress

func (bq *BRQuerier) GetAddress() string

GetAddress returns the address of the persistent blocks in the db.

type Block

type Block struct {
	Datapoint      string `json:"datapoint"`       // complex data would be decoded by using a blockSeparator
	NormalizedTime int64  `json:"normalized-time"` // based on time.Unixnano()
	Type           string `json:"type"`            // would be used to decide the marshalling struct
	Timestamp      string `json:"timestamp"`
}

Block use case block for the TSDB chain

func GetNewBlock

func GetNewBlock(blockType, value string) *Block

GetNewBlock creates and returns a new block with the specified type.

func (Block) Encode

func (b Block) Encode() string

Encode decodes the structure and marshals into a string

func (Block) GetDatapointEnc

func (b Block) GetDatapointEnc() string

GetDatapointEnc returns the datapoint to the caller. The encoded refers to the combined _(containing *|*)_ values in stringified form.

func (Block) GetNormalizedTime

func (b Block) GetNormalizedTime() int64

GetNormalizedTime returns the normalized time of the block.

func (Block) GetNormalizedTimeStringified

func (b Block) GetNormalizedTimeStringified() string

GetNormalizedTimeStringified returns the normalized time of the block.

func (Block) GetTimeStamp

func (b Block) GetTimeStamp() string

GetTimeStamp returns thetimestamp of the block.

func (Block) GetType

func (b Block) GetType() string

GetType returns the type of the block

type Chain

type Chain struct {
	Path           string
	Chain          []Block
	LengthElements int
	Size           uintptr
	// contains filtered or unexported fields
}

Chain contains Blocks arranged as a chain

func NewChain

func NewChain(path string) *Chain

NewChain returns a in-memory chain that implements the TSDB interface.

func (*Chain) Append

func (c *Chain) Append(b Block) *Chain

Append function appends the new block in the chain

func (*Chain) Commit

func (c *Chain) Commit() bool

Commit saves or commits the existing chain in the secondary memory. Returns the success status

func (*Chain) GetPositionalIndexNormalized

func (c *Chain) GetPositionalIndexNormalized(n int64) (int, error)

GetPositionalIndexNormalized Returns block by searching the chain for the NormalizedTime

func (*Chain) Init

func (c *Chain) Init() *Chain

Init initialize Chain properties

func (*Chain) PopPreviousNBlocks

func (c *Chain) PopPreviousNBlocks(n int) (*Chain, error)

PopPreviousNBlocks pops last n elements from chain.

type Reader

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

Reader is used to read persistent time-series samples from the storage as required by the user. This is go-routine safe and hence can handle multiple read request on the same samples as well.

type TSDB

type TSDB interface {
	// Init helps to initialize the tsdb chain for the respective component. This function
	// should be capable to detect existing wals(write ahead log) of the required type and
	// build from the local storage at the init of main thread and return the chain address
	// in order to have a minimal effect on the performance.
	// Takes *path* as path to the existing chain or for creating a new one.
	// Returns address of the chain in RAM.
	Init() (*[]Block, Chain)

	// Append appends a new tsdb block passed as params to the most recent location (or
	// the last location) of the chain. Returns success status.
	Append(b Block) bool

	// GetPositionalIndexNormalized accepts the normalized time, searches for the block with that time
	// using jump search, and returns the address of the block having the specified normalized
	// time.
	GetPositionalIndexNormalized(n int64) (int, error)

	// PopPreviousNBlocks pops or removes **n** previous blocks from the chain and returns
	// success status.
	PopPreviousNBlocks(n uint64) (Chain, error)

	// GetChain returns the positional pointer address of the first element of the chain.
	GetChain() *[]Block

	// Commit saves or commits the chain in storage and returns success status.
	Commit() bool
}

TSDB implements the idea of tsdb

Jump to

Keyboard shortcuts

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