Documentation
¶
Index ¶
- type LeafVisitor
- type Param
- func (p *Param) Dec() error
- func (p *Param) Finalise()
- func (p *Param) Get() interface{}
- func (p *Param) GetFloat64() float64
- func (p *Param) GetInt() int
- func (p *Param) Inc() error
- func (p *Param) Ok() bool
- func (p *Param) Set(value interface{}) error
- func (p *Param) SetFloat64(value float64) error
- func (p *Param) SetInt(value int) error
- func (p *Param) Update(value interface{}) (bool, error)
- func (p *Param) UpdateInt(value int) (bool, error)
- func (p *Param) Walk(visitor ValueVisitor)
- type ParamChannel
- type ParamMQTTBridge
- type Params
- func (ps *Params) Listen(l ParamChannel)
- func (ps *Params) Load()
- func (ps *Params) Metrics(w http.ResponseWriter, req *http.Request)
- func (ps *Params) New(name string) *Param
- func (ps *Params) NewNum(name string) *Param
- func (ps *Params) NewWith(name string, value interface{}) *Param
- func (ps *Params) WalkLeaves(visitor LeafVisitor)
- type ValueVisitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeafVisitor ¶
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) Get ¶
func (p *Param) Get() interface{}
Get returns the current value which may be nil.
func (*Param) GetFloat64 ¶
GetFloat64 returns the current value as a float64.
func (*Param) SetFloat64 ¶
SetFloat64 tries to update the value as a float64.
func (*Param) Walk ¶
func (p *Param) Walk(visitor ValueVisitor)
Walk calls visitor on all leaf values of this parameter.
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 (*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) NewNum ¶
NewNum create a new number param in this group. The Param is zero and invalid.
func (*Params) WalkLeaves ¶
func (ps *Params) WalkLeaves(visitor LeafVisitor)
WalkLeaves calls the given visitor on every leaf value.
type ValueVisitor ¶
ValueVisitor is a callback for leaves in the parameter tree.