defluxio

package
v0.0.0-...-7b34937 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2016 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Overview

(C) 2014 Mathias Dalheimer <md@gonium.net>. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

(C) 2014 Mathias Dalheimer <md@gonium.net>. See LICENSE file for license.

(C) 2014 Mathias Dalheimer <md@gonium.net>. See LICENSE file for license.

Index

Constants

View Source
const (
	STATUS_OK               StatusCode = 200
	STATUS_INTERNAL_ERROR              = 500
	STATUS_NO_DB_CONNECTION            = 501 // TODO: Implement keepalive
	STATUS_NO_UPDATES                  = 502
)

Variables

View Source
var H = hub{
	// contains filtered or unexported fields
}

Functions

func MkSubmitReadingHandler

func MkSubmitReadingHandler(dbchannel chan MeterReading, serverConfig *ServerConfiguration) http.HandlerFunc

Accepts a new reading. Format: {"Timestamp":<ISO8601>,"Value":342.2}

func ServeWs

func ServeWs(w http.ResponseWriter, r *http.Request)

serverWs handles webocket requests from the peer.

func ServerStatus

func ServerStatus(w http.ResponseWriter, r *http.Request)

Types

type APIClientErrorMessage

type APIClientErrorMessage struct {
	Id      string
	Message string
}

type AssetConfig

type AssetConfig struct {
	ViewPath  string
	AssetPath string
}

type ByLastUpdate

type ByLastUpdate struct{ Meters }

func (ByLastUpdate) Less

func (s ByLastUpdate) Less(i, j int) bool

type ByName

type ByName struct{ Meters }

func (ByName) Less

func (s ByName) Less(i, j int) bool

type ByRank

type ByRank struct{ Meters }

func (ByRank) Less

func (s ByRank) Less(i, j int) bool

type ByTimestamp

type ByTimestamp []MeterReading

ByTimestamp implements sort.Interface for []MeterReading based on the timestamp field of a reading.

func (ByTimestamp) Len

func (a ByTimestamp) Len() int

func (ByTimestamp) Less

func (a ByTimestamp) Less(i, j int) bool

func (ByTimestamp) Swap

func (a ByTimestamp) Swap(i, j int)

type DBClient

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

func NewDBClient

func NewDBClient(serverConfig *InfluxDBConfig) (*DBClient, error)

func (DBClient) GetFrequenciesBetween

func (dbc DBClient) GetFrequenciesBetween(meterID string,
	start time.Time, end time.Time) (retval []MeterReading, err error)

func (DBClient) GetLastFrequencies

func (dbc DBClient) GetLastFrequencies(meterID string, amount int) ([]MeterReading, error)

func (DBClient) GetLastFrequency

func (dbc DBClient) GetLastFrequency(meterID string) (MeterReading,
	error)

func (DBClient) MkDBPusher

func (dbc DBClient) MkDBPusher(dbchannel chan MeterReading) (func(), error)

type DeviceConfig

type DeviceConfig struct {
	Path     string
	Baudrate int
}

type ExporterConfiguration

type ExporterConfiguration struct {
	InfluxDB InfluxDBConfig
}

func LoadExporterConfiguration

func LoadExporterConfiguration(configFile string) (cfg *ExporterConfiguration, err error)

func MkDefaultExporterConfiguration

func MkDefaultExporterConfiguration() (cfg ExporterConfiguration)

func (*ExporterConfiguration) Save

func (pc *ExporterConfiguration) Save(configFile string) (err error)

type InfluxDBConfig

type InfluxDBConfig struct {
	Enabled  bool
	Host     string
	Port     int
	Database string
	User     string
	Pass     string
}

type LicenseData

type LicenseData struct {
	GenerationDate string
}

type Meter

type Meter struct {
	Rank      uint16
	ID        string
	Key       string
	Name      string
	Location  string
	Cache     *ReadingCache `json:"-"` // do not export
	CacheSize uint32
}
var BestMeter *Meter

func (*Meter) ActiveWithinLast

func (m *Meter) ActiveWithinLast(deadline time.Duration) (bool, error)

func (*Meter) AppendReading

func (m *Meter) AppendReading(r Reading)

func (*Meter) IsValid

func (m *Meter) IsValid() bool

type MeterReading

type MeterReading struct {
	MeterID string
	Reading Reading
}

TODO: Move MeterID out of MeterReading - too much duplication of the meter name. New type "MeterTimeseries?"

type Meters

type Meters []*Meter

func (Meters) GetBestMeter

func (mc Meters) GetBestMeter(timeout time.Duration) (m *Meter)

func (Meters) IsValid

func (mc Meters) IsValid() bool

func (Meters) Len

func (m Meters) Len() int

func (Meters) StartBestMeterUpdater

func (mc Meters) StartBestMeterUpdater(timeout time.Duration)

func (Meters) String

func (ms Meters) String() string

func (Meters) Swap

func (m Meters) Swap(i, j int)

type NetworkConfig

type NetworkConfig struct {
	Host string
	Port int
}

type ProviderConfiguration

type ProviderConfiguration struct {
	Meter      Meter
	Network    NetworkConfig
	Device     DeviceConfig
	Validation ValidationConfig
}

func LoadProviderConfiguration

func LoadProviderConfiguration(configFile string) (cfg *ProviderConfiguration, err error)

func MkDefaultProviderConfiguration

func MkDefaultProviderConfiguration() (cfg ProviderConfiguration)

func (*ProviderConfiguration) Save

func (pc *ProviderConfiguration) Save(configFile string) (err error)

*

  • Provider Configuration methods

type Reading

type Reading struct {
	Timestamp time.Time
	Value     float64
}

func (Reading) String

func (r Reading) String() (retval string)

type ReadingCache

type ReadingCache struct {
	Cache *ring.Ring
}

The cache implements a cache of readings for a single meter.

func MakeReadingCache

func MakeReadingCache(size uint32) (r *ReadingCache)

func (*ReadingCache) AddReading

func (c *ReadingCache) AddReading(r Reading)

func (*ReadingCache) AllReadings

func (c *ReadingCache) AllReadings() (r []Reading)

func (*ReadingCache) LastReading

func (c *ReadingCache) LastReading() (r Reading, err error)

func (*ReadingCache) NumElements

func (c *ReadingCache) NumElements() (retval int)

func (ReadingCache) String

func (c ReadingCache) String() (retval string)

type ServerConfiguration

type ServerConfiguration struct {
	Meters       Meters
	MeterTimeout time.Duration
	Assets       AssetConfig
	Network      NetworkConfig
	InfluxDB     InfluxDBConfig
}

func LoadServerConfiguration

func LoadServerConfiguration(configFile string) (cfg *ServerConfiguration, err error)

func MkDefaultServerConfiguration

func MkDefaultServerConfiguration() (cfg ServerConfiguration)

func (*ServerConfiguration) Save

func (sc *ServerConfiguration) Save(configFile string) (err error)

* * Server Configuration methods

type ServerStatusData

type ServerStatusData struct {
	Code           StatusCode
	LastValueAdded time.Time
	Message        string
}

type StatusCode

type StatusCode int32

type TsvExporter

type TsvExporter struct {
	Path string
}

func NewTsvExporter

func NewTsvExporter(path string) (*TsvExporter, error)

func (*TsvExporter) ExportDataset

func (tsve *TsvExporter) ExportDataset(timeReadings []MeterReading) error

type ValidationConfig

type ValidationConfig struct {
	SpikeThreshold float64
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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