aggregation

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package aggregation implements Aggregation API

Index

Constants

View Source
const (
	MaxPerPage = 1000
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("API not implemented")
)

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(registry registry.Storage, storage Storage) *API

func (*API) Aggregations

func (api *API) Aggregations() (map[string]Aggregation, error)

Retrieve aggregations from registry api

func (*API) Filter

func (api *API) Filter(w http.ResponseWriter, r *http.Request)

func (*API) Index

func (api *API) Index(w http.ResponseWriter, r *http.Request)

func (*API) Query

func (api *API) Query(w http.ResponseWriter, r *http.Request)

type Aggregation

type Aggregation struct {
	ID         string   `json:"id"`
	Interval   string   `json:"interval"`
	Aggregates []string `json:"aggregates"`
	Retention  string   `json:"retention"`
	Sources    []string `json:"sources"`
}

type DataEntry

type DataEntry struct {
	Name       string
	TimeStart  int64
	TimeEnd    int64
	Aggregates map[string]float64
}

func NewDataEntry

func NewDataEntry() DataEntry

func (*DataEntry) MarshalJSON

func (e *DataEntry) MarshalJSON() ([]byte, error)

type DataSet

type DataSet struct {
	BaseName      string      `json:"bn,omitempty"`
	BaseTimeStart int64       `json:"bts,omitempty"`
	BaseTimeEnd   int64       `json:"bte,omitempty"`
	Entries       []DataEntry `json:"e"`
}

type Index

type Index struct {
	Aggrs []Aggregation `json:"aggregations"`
}

type InfluxAggr

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

InfluxAggr implements a InfluxDB aggregation client for HDS Data API

func (*InfluxAggr) CreateHandler added in v0.6.1

func (a *InfluxAggr) CreateHandler(ds registry.DataSource) error

CreateHandler handles the creation of a new data source

func (*InfluxAggr) DeleteHandler added in v0.6.1

func (a *InfluxAggr) DeleteHandler(ds registry.DataSource) error

DeleteHandler handles deletion of a data source

func (*InfluxAggr) Query

func (a *InfluxAggr) Query(aggr registry.Aggregation, q data.Query, page, perPage int, sources ...registry.DataSource) (DataSet, int, error)

Query retrieves aggregated data

func (*InfluxAggr) UpdateHandler added in v0.6.1

func (a *InfluxAggr) UpdateHandler(oldDS registry.DataSource, newDS registry.DataSource) error

UpdateHandler handles updates of a data source

type RecordSet

type RecordSet struct {
	// URL is the URL of the returned recordset in the Data API
	URL string `json:"url"`
	// Data is a SenML object with data records, where
	// Name (bn and n) constitute the resource URL of the corresponding Data Source(s)
	Data DataSet `json:"data"`
	// Time is the time of query in milliseconds
	Time float64 `json:"time"`
	// Page is the current page in Data pagination
	Page int `json:"page"`
	// PerPage is the results per page in Data pagination
	PerPage int `json:"per_page"`
	// Total is the total #of pages in Data pagination
	Total int `json:"total"`
}

RecordSet describes the recordset returned on querying the Aggr API

type Storage

type Storage interface {
	// Queries data for specified data sources
	Query(aggr registry.Aggregation, q data.Query, page, perPage int, sources ...registry.DataSource) (DataSet, int, error)

	// EventListener includes methods for event handling
	registry.EventListener
}

func NewInfluxAggr

func NewInfluxAggr(influxStorage *data.InfluxStorage) (Storage, error)

NewInfluxAggr returns a new InfluxAggr

Jump to

Keyboard shortcuts

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