metering

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InMemoryMeterForm = forms.Form{
	ErrorMsg: "invalid data encountered in the Redis config form",
	Fields:   []forms.Field{},
}
View Source
var RedisMeterForm = forms.Form{
	ErrorMsg: "invalid data encountered in the Redis config form",
	Fields: []forms.Field{
		{
			Name: "addresses",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsStringList{},
			},
		},
		{
			Name: "database",
			Validators: []forms.Validator{
				forms.IsOptional{Default: 0},
				forms.IsInteger{Min: 0, Max: 100},
			},
		},
		{
			Name: "password",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{},
			},
		},
	},
}

Functions

This section is empty.

Types

type BaseModelMeter

type BaseModelMeter struct {
	Self kodex.Meter
}

func (*BaseModelMeter) AddToModel

func (r *BaseModelMeter) AddToModel(model kodex.Model,
	name string,
	tw kodex.TimeWindow,
	value int64) error

func (*BaseModelMeter) ModelID

func (r *BaseModelMeter) ModelID(model kodex.Model) string

type ByNameAndWindow

type ByNameAndWindow []*kodex.Metric

func (ByNameAndWindow) Len

func (b ByNameAndWindow) Len() int

func (ByNameAndWindow) Less

func (b ByNameAndWindow) Less(i, j int) bool

func (ByNameAndWindow) Swap

func (b ByNameAndWindow) Swap(i, j int)

type InMemoryMeter

type InMemoryMeter struct {
	BaseModelMeter
}

func MakeInMemoryMeter

func MakeInMemoryMeter(config map[string]interface{}) (*InMemoryMeter, error)

func (*InMemoryMeter) Add

func (i *InMemoryMeter) Add(id string, name string, data map[string]string, tw kodex.TimeWindow, value int64) error

Add the given value to the metric

func (*InMemoryMeter) AddToModel

func (i *InMemoryMeter) AddToModel(model kodex.Model, name string, tw kodex.TimeWindow, value int64) error

func (*InMemoryMeter) Get

func (i *InMemoryMeter) Get(id string, name string, data map[string]string, tw kodex.TimeWindow) (*kodex.Metric, error)

Return the metric and its assigned quota

func (*InMemoryMeter) ModelID

func (i *InMemoryMeter) ModelID(model kodex.Model) string

func (*InMemoryMeter) N

func (i *InMemoryMeter) N(id string, to int64, n int64, name, twType string) ([]*kodex.Metric, error)

func (*InMemoryMeter) Range

func (i *InMemoryMeter) Range(id string, from, to int64, name, twType string) ([]*kodex.Metric, error)

Return metrics for a given ID and time interval

type RedisMeter

type RedisMeter struct {
	BaseModelMeter
	// contains filtered or unexported fields
}

func MakeRedisMeter

func MakeRedisMeter(config map[string]interface{}) (*RedisMeter, error)

func (*RedisMeter) Add

func (r *RedisMeter) Add(id string, name string, data map[string]string, tw kodex.TimeWindow, value int64) error

func (*RedisMeter) Get

func (r *RedisMeter) Get(id string, name string, data map[string]string, tw kodex.TimeWindow) (*kodex.Metric, error)

func (*RedisMeter) GetByTimeIds

func (r *RedisMeter) GetByTimeIds(id string, from, to int64, tId, maxTId int64, name, twType string) ([]*kodex.Metric, error)

func (*RedisMeter) N

func (r *RedisMeter) N(id string, to, n int64, name, twType string) ([]*kodex.Metric, error)

func (*RedisMeter) Range

func (r *RedisMeter) Range(id string, from, to int64, name, twType string) ([]*kodex.Metric, error)

func (*RedisMeter) Teardown

func (r *RedisMeter) Teardown() error

Jump to

Keyboard shortcuts

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