models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meter

type Meter struct {
	ID            string            `json:"id" yaml:"id"`
	Name          string            `json:"name" yaml:"name"`
	Description   string            `json:"description,omitempty" yaml:"description,omitempty"`
	Labels        map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Type          string            `json:"type" yaml:"type"`
	Aggregation   MeterAggregation  `json:"aggregation" yaml:"aggregation"`
	ValueProperty string            `json:"valueProperty,omitempty" yaml:"valueProperty,omitempty"`
	GroupBy       []string          `json:"groupBy,omitempty" yaml:"groupBy,omitempty"`
	WindowSize    WindowSize        `json:"windowSize,omitempty" yaml:"windowSize,omitempty"`
}

func NewMeter

func NewMeter(id, name, meterType, valueProperty string, aggregation MeterAggregation, options *MeterOptions) (*Meter, error)

func (*Meter) AggregateMeterValues

func (m *Meter) AggregateMeterValues(values []*MeterValue, windowSize *WindowSize) ([]*MeterValue, error)

func (*Meter) Render

func (m *Meter) Render(w http.ResponseWriter, r *http.Request) error

func (*Meter) Validate

func (m *Meter) Validate() error

type MeterAggregation

type MeterAggregation string
const (
	MeterAggregationSum    MeterAggregation = "SUM"
	MeterAggregationCount  MeterAggregation = "COUNT"
	MeterAggregationAvg    MeterAggregation = "AVG"
	MeterAggregationMin    MeterAggregation = "MIN"
	MeterAggregationMax    MeterAggregation = "MAX"
	MeterAggregationLatest MeterAggregation = "LATEST_BY_OFFSET"

	// these types can not be used for further aggregations
	MeterAggregationCountDistinct MeterAggregation = "COUNT_DISTINCT"
)

type MeterFilter

type MeterFilter struct {
	Property string              `json:"property" yaml:"property"`
	Operator MeterFilterOperator `json:"operator" yaml:"operator"`
	Value    string              `json:"value" yaml:"value"`
}

type MeterFilterOperator

type MeterFilterOperator string
const (
	// MeterFilterOperatorIn        MeterFilterOperator = "IN"
	// MeterFilterOperatorNotIn     MeterFilterOperator = "NOT IN"
	MeterFilterOperatorEquals    MeterFilterOperator = "EQ"
	MeterFilterOperatorNot       MeterFilterOperator = "NEQ"
	MeterFilterLowerThan         MeterFilterOperator = "LT"
	MeterFilterLowerThanOrEq     MeterFilterOperator = "LTE"
	MeterFilterGreaterThan       MeterFilterOperator = "GT"
	MeterFilterGreaterThanOrEq   MeterFilterOperator = "GTE"
	MeterFilterOperatorIsNull    MeterFilterOperator = "IS NULL"
	MeterFilterOperatorIsNotNull MeterFilterOperator = "IS NOT NULL"
)

type MeterOptions

type MeterOptions struct {
	Description string
	Labels      map[string]string
	GroupBy     []string
	WindowSize  *WindowSize
}

type MeterValue

type MeterValue struct {
	Subject     string            `json:"subject"`
	WindowStart time.Time         `json:"windowStart"`
	WindowEnd   time.Time         `json:"windowEnd"`
	Value       float64           `json:"value"`
	GroupBy     map[string]string `json:"groupBy"`
}

func (*MeterValue) Render

func (m *MeterValue) Render(w http.ResponseWriter, r *http.Request) error

type WindowSize

type WindowSize string
const (
	WindowSizeMinute WindowSize = "MINUTE"
	WindowSizeHour   WindowSize = "HOUR"
	WindowSizeDay    WindowSize = "DAY"
)

func (WindowSize) Duration

func (w WindowSize) Duration() time.Duration

Duration returns the duration of the window size

Jump to

Keyboard shortcuts

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