Documentation ¶
Overview ¶
Package store implements database store code -- currently Genji and Influxdb. Also contains NATS handlers to receive data. This allows us to keep the db write functions private and force all write data through NATS, and thus makes it easy to observe any data changes.
Index ¶
Constants ¶
const ( StoreTypeMemory Type = "memory" StoreTypeBolt = "bolt" StoreTypeBadger = "badger" )
define valid store types
Variables ¶
var DBVersion = 1
DBVersion for this version of siot
Functions ¶
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db represents the store for the application
type Influx ¶
type Influx struct {
// contains filtered or unexported fields
}
Influx represents and influxdb that we can write points to
func NewInflux ¶
func NewInflux(config *InfluxConfig) *Influx
NewInflux creates an influx helper client
func (*Influx) CheckConfig ¶
func (i *Influx) CheckConfig(config *InfluxConfig)
CheckConfig checks influx config and re-init if necessary
type InfluxConfig ¶
InfluxConfig represents an influxdb config
func NodeToInfluxConfig ¶
func NodeToInfluxConfig(node data.NodeEdge) (*InfluxConfig, error)
NodeToInfluxConfig converts a node to an influx config
type NatsHandler ¶
NatsHandler implements the SIOT NATS api
func NewNatsHandler ¶
func NewNatsHandler(db *Db, authToken, server string, key NewTokener) *NatsHandler
NewNatsHandler creates a new NATS client for handling SIOT requests
func (*NatsHandler) Connect ¶
func (nh *NatsHandler) Connect() (*natsgo.Conn, error)
Connect to NATS server and set up handlers for things we are interested in
func (*NatsHandler) StartMetrics ¶
func (nh *NatsHandler) StartMetrics(nodeID string) error
StartMetrics for various handling operations. Metrics are sent to the node ID given
func (*NatsHandler) StartUpdate ¶
func (nh *NatsHandler) StartUpdate(id, url string) error
StartUpdate starts an update
type NewTokener ¶ added in v0.0.45
NewTokener provides a new authentication token.