data

package
v1.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Overview

Package data implements Data API

Package senmltest implements senml testing utilities

Index

Constants

View Source
const (
	MaxPerPage = 1000

	//value for ParamDenormalize
	TimeField       = "time"
	TimeFieldShort  = "t"
	NameField       = "name"
	NameFieldShort  = "n"
	UnitField       = "unit"
	UnitFieldShort  = "u"
	ValueField      = "value"
	ValueFieldShort = "v"
	SumField        = "sum"
	SumFieldShort   = "s"
)
View Source
const (
	INFLUXDB       = "influxdb"
	MONGODB        = "mongodb"
	SENMLSTORE     = "senmlstore"
	SQLITE         = "sqlite"
	DRIVER_SQLITE3 = "sqlite3"
)

Variables

This section is empty.

Functions

func CompareRecords

func CompareRecords(r1 senml.Record, r2 senml.Record) (same bool)

func CompareSenml

func CompareSenml(s1 senml.Pack, s2 senml.Pack) (same bool)

func Diff_name_diff_types

func Diff_name_diff_types() senml.Pack

func FromSenmlTime

func FromSenmlTime(t float64) time.Time

func GetUrlFromQuery

func GetUrlFromQuery(q Query, id ...string) (url string)

func Same_name_same_types

func Same_name_same_types(count int, stream registry.DataStream, decremental bool) senml.Pack

func SupportedBackends added in v0.6.1

func SupportedBackends(name string) bool

SupportedBackends returns true if the backend is listed as true

func ToSenmlTime

func ToSenmlTime(t time.Time) float64

Types

type API added in v0.6.1

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

API describes the RESTful HTTP data API

func NewAPI added in v0.6.1

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

NewAPI returns the configured Data API

func (*API) Query added in v0.6.1

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

Query is a handler for querying data Expected parameters: id(s), optional: pagination, query string

func (*API) Submit added in v0.6.1

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

Submit is a handler for submitting a new data point Expected parameters: id(s)

func (*API) SubmitWithoutID added in v0.6.1

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

SubmitWithoutID is a handler for submitting a new data point Expected parameters: none

type DenormMask

type DenormMask int
const (
	FName DenormMask = 1 << iota
	FTime
	FUnit
	FValue
	FSum
)

type MQTTConnector

type MQTTConnector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMQTTConnector

func NewMQTTConnector(storage Storage, clientID string) (*MQTTConnector, error)

func (*MQTTConnector) CreateHandler added in v0.6.1

func (c *MQTTConnector) CreateHandler(ds registry.DataStream) error

CreateHandler handles the creation of a new Data stream

func (*MQTTConnector) DeleteHandler added in v0.6.1

func (c *MQTTConnector) DeleteHandler(oldDS registry.DataStream) error

DeleteHandler handles deletion of a Data stream

func (*MQTTConnector) Start added in v0.6.1

func (c *MQTTConnector) Start(reg registry.Storage) error

func (*MQTTConnector) UpdateHandler added in v0.6.1

func (c *MQTTConnector) UpdateHandler(oldDS registry.DataStream, newDS registry.DataStream) error

UpdateHandler handles updates of a data stream

type Manager

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

type Query

type Query struct {
	From        time.Time
	To          time.Time
	Sort        string
	Page        int
	Limit       int
	PerPage     int
	Denormalize DenormMask
	// contains filtered or unexported fields
}

func ParseQueryParameters

func ParseQueryParameters(form url.Values) (Query, error)

type RecordSet

type RecordSet struct {
	// SelfLink is the SelfLink of the returned recordset in the Data API
	SelfLink string `json:"selfLink"`

	// Data is a SenML object with data records, where
	// Name (bn and n) constitute the resource BrokerURL of the corresponding Data streams(s)
	Data senml.Pack `json:"data"`

	// Time is the time of query in seconds
	TimeTook float64 `json:"took"`

	//Next link for the same query, in case there more entries to follow for the same query
	NextLink string `json:"nextLink,omitempty"`

	//Total number of entries
	Count *int `json:"count,omitempty"`
}

RecordSet describes the recordset returned on querying the Data API

type RemoteClient

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

func NewRemoteClient

func NewRemoteClient(serverEndpoint string, ticket *obtainer.Client) (*RemoteClient, error)

func (*RemoteClient) Query

func (c *RemoteClient) Query(q Query, id ...string) (*RecordSet, error)

func (*RemoteClient) Submit

func (c *RemoteClient) Submit(data []byte, contentType string, id ...string) error

Submit data for ingestion, where: data - is a byte array with actual data contentType - mime-type of the data (will be set in the header) id... - ID (or array of IDs) of data streams for which the data is being submitted

type SqlStorage

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

SqlStorage implements a SqlDB storage client for HDS Data API

func NewSqlStorage

func NewSqlStorage(conf common.DataConf) (storage *SqlStorage, disconnect_func func() error, err error)

func (*SqlStorage) CreateHandler

func (s *SqlStorage) CreateHandler(ds registry.DataStream) error

CreateHandler handles the creation of a new DataStream

func (*SqlStorage) DeleteHandler

func (s *SqlStorage) DeleteHandler(ds registry.DataStream) error

DeleteHandler handles deletion of a DataStream

func (*SqlStorage) Disconnect

func (s *SqlStorage) Disconnect() error

func (*SqlStorage) Query

func (s *SqlStorage) Query(q Query, streams ...*registry.DataStream) (pack senml.Pack, total *int, err error)

func (*SqlStorage) Submit

func (s *SqlStorage) Submit(data map[string]senml.Pack, streams map[string]*registry.DataStream) (err error)

func (*SqlStorage) UpdateHandler

func (s *SqlStorage) UpdateHandler(oldDS registry.DataStream, newDS registry.DataStream) error

UpdateHandler handles updates of a DataStream

type Storage

type Storage interface {
	// Adds data points for multiple data streams
	// data is a map where keys are data stream ids
	// streams is a map where keys are data stream ids
	Submit(data map[string]senml.Pack, streams map[string]*registry.DataStream) error

	// Queries data for specified data streams
	//Query(q Query, page, PerPage int, streams ...*registry.DataStream) (senml.Pack, int, error)
	Query(q Query, streams ...*registry.DataStream) (pack senml.Pack, total *int, err error)

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

Storage is an interface of a Data storage backend

type Subscription

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

Jump to

Keyboard shortcuts

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