param

package
v0.0.0-...-87985d3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeafVisitor

type LeafVisitor func(p *Param, name string, value reflect.Value)

LeafVisitor is called on every param value.

type Param

type Param struct {
	Name string
	// contains filtered or unexported fields
}

Param is a value or a struct that has age and validity. Updating a Param also fires an event.

func (*Param) Dec

func (p *Param) Dec() error

Dec tries to decrement the integer value.

func (*Param) Finalise

func (p *Param) Finalise()

Finalise marks the param as always valid.

func (*Param) Get

func (p *Param) Get() interface{}

Get returns the current value which may be nil.

func (*Param) GetFloat64

func (p *Param) GetFloat64() float64

GetFloat64 returns the current value as a float64.

func (*Param) GetInt

func (p *Param) GetInt() int

GetInt returns the current value as an int.

func (*Param) Inc

func (p *Param) Inc() error

Inc tries to increment the integer value.

func (*Param) Ok

func (p *Param) Ok() bool

Ok return true if the value has been recently updated.

func (*Param) Set

func (p *Param) Set(value interface{}) error

Set the value, update validity, and notify listeners.

func (*Param) SetFloat64

func (p *Param) SetFloat64(value float64) error

SetFloat64 tries to update the value as a float64.

func (*Param) SetInt

func (p *Param) SetInt(value int) error

SetInt tries to update the value as an int.

func (*Param) Update

func (p *Param) Update(value interface{}) (bool, error)

Update tries to update the value.

func (*Param) UpdateInt

func (p *Param) UpdateInt(value int) (bool, error)

UpdateInt tries to update the value as an int.

func (*Param) Walk

func (p *Param) Walk(visitor ValueVisitor)

Walk calls visitor on all leaf values of this parameter.

type ParamChannel

type ParamChannel chan *Param

ParamChannel passes changes to a Param.

type ParamMQTTBridge

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

ParamMQTTBridge exposes parameters over MQTT.

func NewParamMQTTBridge

func NewParamMQTTBridge(params *Params, adaptor *mqtt.Adaptor, device string) *ParamMQTTBridge

NewParamMQTTBridge creates a new two way connection between MQTT and the given params.

type Params

type Params struct {
	Name string
	// contains filtered or unexported fields
}

Params is a group of parameters that can be listened to.

func NewParams

func NewParams(name string) *Params

NewParams creates a new group of parameters with the given root name.

func (*Params) Listen

func (ps *Params) Listen(l ParamChannel)

Listen to changes on any parameter in this group.

func (*Params) Load

func (ps *Params) Load()

Load fetches the supplied values from Viper and updates all matching params.

func (*Params) Metrics

func (ps *Params) Metrics(w http.ResponseWriter, req *http.Request)

Metrics generates Prometheus/Borgmon compatible metrics from all params.

func (*Params) New

func (ps *Params) New(name string) *Param

New creates a new Param in this group. The Param is uninitialised and invalid.

func (*Params) NewNum

func (ps *Params) NewNum(name string) *Param

NewNum create a new number param in this group. The Param is zero and invalid.

func (*Params) NewWith

func (ps *Params) NewWith(name string, value interface{}) *Param

NewWith create a new, valid Param in this group using the given value.

func (*Params) WalkLeaves

func (ps *Params) WalkLeaves(visitor LeafVisitor)

WalkLeaves calls the given visitor on every leaf value.

type ValueVisitor

type ValueVisitor func(p *Param, path []string, value interface{})

ValueVisitor is a callback for leaves in the parameter tree.

Jump to

Keyboard shortcuts

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