db

package
v0.0.0-...-1d00dcf Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	State string `json:"state"`
}

Account reprensets a user account

type DeviceManager

type DeviceManager interface {
	GetRelay(string) (*Relay, error)
	GetSensor(string, string) (*Sensor, error)
	CreateSensor(string, string) (*Sensor, error)
}

DeviceManager allows for storage & retrieval of devices (sensors & relays)

type DynamoDAO

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

DynamoDAO represents a database to be used for reading & writing measurements and managing devices

func NewDynamoDAO

func NewDynamoDAO(dynamoDBService dynamodbiface.DynamoDBAPI) *DynamoDAO

NewDynamoDAO builds a new DynamoDAO instance

func (*DynamoDAO) CreateSensor

func (d *DynamoDAO) CreateSensor(sensorID string, accountID string) (*Sensor, error)

CreateSensor creates a new sensor by ID within an account

func (*DynamoDAO) GetRelay

func (d *DynamoDAO) GetRelay(relayID string) (relay *Relay, err error)

GetRelay retrieves a relay record by ID

func (*DynamoDAO) GetSensor

func (d *DynamoDAO) GetSensor(sensorID string, accountID string) (*Sensor, error)

GetSensor retrieves a sensor by ID within the context of an account

type InfluxDAO

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

InfluxDAO represents a DAO capable of interacting with InfluxDB

func NewInfluxDAO

func NewInfluxDAO(address string, username string, password string, databaseName string, deviceManager DeviceManager) (*InfluxDAO, error)

NewInfluxDAO creates a new DAO for interacting with InfluxDB

func (*InfluxDAO) WriteSensorReading

func (i *InfluxDAO) WriteSensorReading(r *msg.SensorReadingQueueMessage) error

WriteSensorReading will record the Sensor Reading data, first verifying that a corresponding reporting device and account exist and are active

type MeasurementWriter

type MeasurementWriter interface {
	WriteSensorReading(*msg.SensorReadingQueueMessage) error
}

MeasurementWriter is capable of writing sensor readings to storage

type Relay

type Relay struct {
	ID        string `json:"id"`
	AccountID string `json:"account_id"`
	Name      string `json:"name"`
	State     string `json:"state"`
}

Relay represents a StreamMarker relay

type Sensor

type Sensor struct {
	ID              string  `json:"id"`
	AccountID       string  `json:"account_id"`
	Name            string  `json:"name"`
	State           string  `json:"state"`
	SampleFrequency int64   `json:"sample_frequency"`
	LocationEnabled bool    `json:"location_enabled"`
	Latitude        float64 `json:"latitude,omitempty"`
	Longitude       float64 `json:"longitude,omitempty"`
}

Sensor represents a Sensor capable of taking measurements

Jump to

Keyboard shortcuts

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