evdb

package module
v0.1.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 14 Imported by: 0

README

go-meter

Metering for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(scheme string, op Opener) error

func SyncTask

func SyncTask(e *events.Event, db Storer) func(time.Time) error

SyncTask dumps an Event to an EventStore

Types

type DB

type DB interface {
	Scanner
	Store
	Close() error
}

func Open

func Open(configURL string, events ...string) (DB, error)

type DataPoint

type DataPoint struct {
	Timestamp int64
	Value     float64
}

DataPoint is a time/value pair

func (DataPoint) AppendJSON

func (p DataPoint) AppendJSON(data []byte) []byte

AppendJSON appends JSON to a buffer

func (DataPoint) MarshalJSON

func (p DataPoint) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*DataPoint) UnmarshalJSON

func (p *DataPoint) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type DataPoints

type DataPoints []DataPoint

DataPoints is a collection of DataPoints

func BlankData

func BlankData(t *TimeRange, v float64) DataPoints

func (DataPoints) Add

func (s DataPoints) Add(t int64, v float64) DataPoints

Add adds a point

func (DataPoints) AppendJSON

func (s DataPoints) AppendJSON(data []byte) []byte

AppendJSON appends points as JSON to a buffer

func (DataPoints) Avg

func (s DataPoints) Avg() float64

Avg returns the average value of all points

func (DataPoints) Copy

func (s DataPoints) Copy() DataPoints

Copy creates a copy of s

func (DataPoints) Fill

func (s DataPoints) Fill(v float64)

func (DataPoints) First

func (s DataPoints) First() *DataPoint

First returns a pointer to the first point

func (DataPoints) Get

func (s DataPoints) Get(i int) *DataPoint

Get returns a pointer to the i-th point

func (DataPoints) Last

func (s DataPoints) Last() *DataPoint

Last returns a pointer to the last point

func (DataPoints) MarshalJSON

func (s DataPoints) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshal interface

func (DataPoints) Reset

func (s DataPoints) Reset() DataPoints

func (DataPoints) SeekLeft

func (s DataPoints) SeekLeft(ts int64) DataPoints

func (DataPoints) SeekRight

func (s DataPoints) SeekRight(ts int64) DataPoints

func (DataPoints) Slice

func (s DataPoints) Slice(start, end int64) DataPoints

func (DataPoints) Sum

func (s DataPoints) Sum() (sum float64)

Sum returns the sum of the values of all points

type EventSummaries

type EventSummaries struct {
	Labels []string
	Events []string
	Data   []EventSummary
}

EventSummaries is a result summary format

func (*EventSummaries) Table

func (s *EventSummaries) Table() Table

Table returns event summaries as a table

type EventSummary

type EventSummary struct {
	Values []string
	Totals map[string]float64
}

EventSummary groups values with totals

func (*EventSummary) TableRow

func (r *EventSummary) TableRow(events []string) []interface{}

TableRow is a helper to convert event summary to table

type Field

type Field struct {
	Label string
	Value string
}

Field is a Label/Value pair

type FieldSummaries

type FieldSummaries []FieldSummary

FieldSummaries is a slice of FieldSummary results

type FieldSummary

type FieldSummary struct {
	Event  string             `json:"event"`
	Label  string             `json:"label"`
	Values map[string]float64 `json:"values"`
}

FieldSummary is a query result presented as a summary of field values

func (*FieldSummary) Add

func (s *FieldSummary) Add(value string, n float64)

Add ads a value to a field summary

type Fields

type Fields []Field

Fields is a collection of Label/Value pairs

func (Fields) AppendBlob

func (fields Fields) AppendBlob(b []byte) ([]byte, error)

AppendBlob implements blob.Appender interface

func (Fields) AppendGrouped

func (fields Fields) AppendGrouped(grouped Fields, empty string, groups []string) Fields

func (Fields) AppendValues

func (fields Fields) AppendValues(dst []string, empty string, labels ...string) []string

AppendValues appends the values for the labels in order

func (Fields) Copy

func (fields Fields) Copy() Fields

Copy clones a collection of fields

func (Fields) Equal

func (fields Fields) Equal(other Fields) bool

Equal checks if two Fields are equal

func (Fields) FromBlob

func (fields Fields) FromBlob(b []byte) (Fields, []byte)

ShiftBlob implements blob.Shifter interface

func (Fields) Get

func (fields Fields) Get(label string) (string, bool)

Get returns the value of label

func (Fields) Len

func (fields Fields) Len() int

func (Fields) Less

func (fields Fields) Less(i, j int) bool

func (Fields) Map

func (fields Fields) Map() map[string]string

Map converts a Fields collection to a map

func (Fields) MarshalJSON

func (fields Fields) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Fields) Reset

func (fields Fields) Reset() Fields

Reset resets Fields to empty

func (Fields) Set

func (fields Fields) Set(label, value string) Fields

Set sets a label to a value

func (*Fields) ShiftBlob

func (fields *Fields) ShiftBlob(b []byte) ([]byte, error)

ShiftBlob implements blob.Shifter interface

func (Fields) Sorted

func (fields Fields) Sorted() Fields

func (Fields) Swap

func (fields Fields) Swap(i, j int)

func (*Fields) UnmarshalBinary

func (fields *Fields) UnmarshalBinary(b []byte) error

func (*Fields) UnmarshalJSON

func (fields *Fields) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type MatchFields

type MatchFields map[string]Matcher

func (MatchFields) Add

func (mf MatchFields) Add(label string, m Matcher) MatchFields

func (MatchFields) Copy

func (mf MatchFields) Copy() MatchFields

func (MatchFields) Match

func (mf MatchFields) Match(fields Fields) bool

func (MatchFields) MatchBytes

func (mf MatchFields) MatchBytes(label string, b []byte) bool

func (MatchFields) MatchString

func (mf MatchFields) MatchString(label string, s string) bool

func (MatchFields) Merge

func (mf MatchFields) Merge(other MatchFields) MatchFields

func (MatchFields) Set

func (mf MatchFields) Set(label string, m Matcher) MatchFields

type MatchPrefix

type MatchPrefix string

func (MatchPrefix) Match

func (prefix MatchPrefix) Match(b []byte) bool

func (MatchPrefix) MatchString

func (prefix MatchPrefix) MatchString(s string) bool

type MatchString

type MatchString string

func (MatchString) Match

func (m MatchString) Match(b []byte) bool

func (MatchString) MatchString

func (m MatchString) MatchString(s string) bool

func (MatchString) String

func (m MatchString) String() string

type MatchSuffix

type MatchSuffix string

func (MatchSuffix) Match

func (suffix MatchSuffix) Match(b []byte) bool

func (MatchSuffix) MatchString

func (suffix MatchSuffix) MatchString(s string) bool

type Matcher

type Matcher interface {
	Match([]byte) bool
	MatchString(string) bool
}

func MatchAny

func MatchAny(values ...string) Matcher

MatchAny creates a Matcher matching any value

type Matchers

type Matchers []Matcher

func (Matchers) Match

func (mm Matchers) Match(b []byte) bool

func (Matchers) MatchString

func (mm Matchers) MatchString(s string) bool
func (mm Matchers) String() string {
	return fmt.Sprintf("%s", ([]Matcher)(mm))
}

type Opener

type Opener interface {
	Open(configURL string, events ...string) (DB, error)
}

type Result

type Result struct {
	TimeRange
	Event  string     `json:"event,omitempty"`
	Fields Fields     `json:"fields,omitempty"`
	Data   DataPoints `json:"data,omitempty"`
}

Result is a query result

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

type Results

type Results []Result

Results is a slice of results

func (Results) Add

func (results Results) Add(event string, fields Fields, t int64, v float64) Results

Add adds a result

func (Results) EventSummaries

func (results Results) EventSummaries(empty string) *EventSummaries

EventSummaries groups results as EventSummaries

func (Results) FieldSummaries

func (results Results) FieldSummaries() (s FieldSummaries)

FieldSummaries converts a series of results to a slice of FieldSummary results

func (Results) ScanQuery

func (results Results) ScanQuery(_ context.Context, q *ScanQuery) (Results, error)

ScanQuery implements ScanQuerier interface

func (Results) Totals

func (results Results) Totals() (totals Totals)

Totals returns a totals-only Results slice

type ScanQuerier

type ScanQuerier interface {
	ScanQuery(ctx context.Context, q *ScanQuery) (Results, error)
}

type ScanQueries

type ScanQueries []ScanQuery

func (ScanQueries) Compact

func (queries ScanQueries) Compact() ScanQueries

Compact merges overlapping queries

func (ScanQueries) Merge

func (queries ScanQueries) Merge(other ...ScanQuery) ScanQueries

func (ScanQueries) MergeQuery

func (queries ScanQueries) MergeQuery(q *ScanQuery) ScanQueries

MergeQuery merges a query if it overlaps or appends it to the query list

type ScanQuery

type ScanQuery struct {
	Event string
	TimeRange
	Fields MatchFields
}

ScanQuery is a query over a range of time

type Scanner

type Scanner interface {
	Scan(ctx context.Context, queries ...ScanQuery) (Results, error)
}

func NewScanner

func NewScanner(q ScanQuerier) Scanner

NewScanner convers a ScanQuerier to a Scanner

type Snapshot

type Snapshot struct {
	Time     time.Time        `json:"time,omitempty"`
	Labels   []string         `json:"labels"`
	Counters []events.Counter `json:"counters"`
}

Snapshot is a snaphot of event counters

func (*Snapshot) Copy

func (s *Snapshot) Copy() *Snapshot

func (*Snapshot) Reset

func (s *Snapshot) Reset()

type Store

type Store interface {
	Storer(event string) Storer
}

Store provides snapshot storers for events

type Storer

type Storer interface {
	Store(s *Snapshot) error
}

Storer stores event snapshots

type Table

type Table struct {
	Columns []interface{}   `json:"cols"`
	Data    [][]interface{} `json:"data"`
}

Table holds generic tabular data

type TimeRange

type TimeRange struct {
	Start time.Time     `json:"start"`
	End   time.Time     `json:"end"`
	Step  time.Duration `json:"step"`
}

TimeRange is a range of time with a specific step

func (*TimeRange) Each

func (tr *TimeRange) Each(fn func(time.Time, int))

Each calls a function for each step in a TimeRange

func (*TimeRange) NumSteps

func (tr *TimeRange) NumSteps() int

NumSteps calculates the number of steps in a TimeRange

func (TimeRange) Offset

func (tr TimeRange) Offset(d time.Duration) TimeRange

Offset offsets a TimeRange by a duration

func (*TimeRange) Rel

func (tr *TimeRange) Rel(other *TimeRange) TimeRel

Rel finds the relation between two time ranges

func (*TimeRange) Truncate

func (tr *TimeRange) Truncate(tm time.Time) time.Time

Truncate truncates time to the TimeRange step

type TimeRel

type TimeRel int

TimeRel is a relation between two time ranges

const (
	TimeRelNone TimeRel = iota
	TimeRelAround
	TimeRelOverlapsBefore
	TimeRelBefore
	TimeRelEqual
	TimeRelAfter
	TimeRelOverlapsAfter
	TimeRelBetween
)

TimeRel enum

type Total

type Total struct {
	Event  string  `json:"event"`
	Fields Fields  `json:"fields,omitempty"`
	Total  float64 `json:"total"`
}

type Totals

type Totals []Total

Directories

Path Synopsis
cmd
Package evbadger provides an evdb backend using dgraph.io/badger key-value store
Package evbadger provides an evdb backend using dgraph.io/badger key-value store
Package evredis provides an evdb backend using Redis
Package evredis provides an evdb backend using Redis
internal

Jump to

Keyboard shortcuts

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