db

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 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 Db

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

Db is used for all db access in the application. We will eventually turn this into an interface to handle multiple Db backends.

func NewDb

func NewDb(dataDir string) (*Db, error)

NewDb creates a new Db instance for the app

func (*Db) Device

func (db *Db) Device(id string) (ret data.Device, err error)

Device returns data for a particular device

func (*Db) DeviceDelete

func (db *Db) DeviceDelete(id string) error

DeviceDelete deletes a device from the database

func (*Db) DeviceGetCmd

func (db *Db) DeviceGetCmd(id string) (data.DeviceCmd, error)

DeviceGetCmd gets a cmd for a device. If the cmd is no null, the command is deleted, and the cmdPending flag cleared in the Device data structure.

func (*Db) DeviceSample

func (db *Db) DeviceSample(id string, sample data.Sample) error

DeviceSample processes a sample for a particular device

func (*Db) DeviceSetCmd

func (db *Db) DeviceSetCmd(cmd data.DeviceCmd) error

DeviceSetCmd sets a cmd for a device, and sets the CmdPending flag in the device structure.

func (*Db) DeviceSetVersion

func (db *Db) DeviceSetVersion(id string, ver data.DeviceVersion) error

DeviceSetVersion sets a cmd for a device, and sets the CmdPending flag in the device structure.

func (*Db) DeviceUpdate

func (db *Db) DeviceUpdate(device data.Device) error

DeviceUpdate updates a devices state in the database

func (*Db) DeviceUpdateConfig

func (db *Db) DeviceUpdateConfig(id string, config data.DeviceConfig) error

DeviceUpdateConfig updates the config for a particular device

func (*Db) Devices

func (db *Db) Devices() (ret []data.Device, err error)

Devices returns all devices

type Influx

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

Influx represents and influxdb that we can write samples to

func NewInflux

func NewInflux(url, dbName, user, password string) (*Influx, error)

NewInflux creates an influx helper client

func (*Influx) WriteSamples

func (i *Influx) WriteSamples(samples []data.Sample) error

WriteSamples to influxdb

Jump to

Keyboard shortcuts

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