Documentation ¶
Overview ¶
Package data implements Data API
Index ¶
- Constants
- func GetUrlFromQuery(q Query, id ...string) (url string)
- func SupportedBackends(name string) bool
- type API
- type LightdbStorage
- func (s *LightdbStorage) CreateHandler(ds registry.DataStream) error
- func (s *LightdbStorage) DeleteHandler(ds registry.DataStream) error
- func (s *LightdbStorage) Disconnect() error
- func (s *LightdbStorage) Query(q Query, sources ...*registry.DataStream) (senml.Pack, int, *time.Time, error)
- func (s *LightdbStorage) Submit(data map[string]senml.Pack) error
- func (s *LightdbStorage) UpdateHandler(oldDS registry.DataStream, newDS registry.DataStream) error
- type MQTTConnector
- type Manager
- type Query
- type RecordSet
- type RemoteClient
- type Storage
- type Subscription
Constants ¶
const ( INFLUXDB = "influxdb" MONGODB = "mongodb" SENMLSTORE = "senmlstore" )
const (
MaxPerPage = 1000
)
Variables ¶
This section is empty.
Functions ¶
func GetUrlFromQuery ¶
func SupportedBackends ¶ added in v0.6.1
SupportedBackends returns true if the backend is listed as true
Types ¶
type API ¶ added in v0.6.1
type API struct {
// contains filtered or unexported fields
}
API describes the RESTful HTTP 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 LightdbStorage ¶
type LightdbStorage struct {
// contains filtered or unexported fields
}
func NewSenmlStorage ¶
func NewSenmlStorage(conf common.DataConf) (storage *LightdbStorage, disconnect_func func() error, err error)
func (*LightdbStorage) CreateHandler ¶
func (s *LightdbStorage) CreateHandler(ds registry.DataStream) error
CreateHandler handles the creation of a new data source
func (*LightdbStorage) DeleteHandler ¶
func (s *LightdbStorage) DeleteHandler(ds registry.DataStream) error
DeleteHandler handles deletion of a data source
func (*LightdbStorage) Disconnect ¶
func (s *LightdbStorage) Disconnect() error
func (*LightdbStorage) Query ¶
func (s *LightdbStorage) Query(q Query, sources ...*registry.DataStream) (senml.Pack, int, *time.Time, error)
func (*LightdbStorage) UpdateHandler ¶
func (s *LightdbStorage) UpdateHandler(oldDS registry.DataStream, newDS registry.DataStream) error
UpdateHandler handles updates of a data source
type MQTTConnector ¶
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 source
func (*MQTTConnector) DeleteHandler ¶ added in v0.6.1
func (c *MQTTConnector) DeleteHandler(oldDS registry.DataStream) error
DeleteHandler handles deletion of a data source
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 source
type Query ¶
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 Sources(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"` }
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 sources for which the data is being submitted
type Storage ¶
type Storage interface { // Adds data points for multiple data sources // data is a map where keys are data source ids // sources is a map where keys are data source ids Submit(data map[string]senml.Pack) error // Queries data for specified data sources //Query(q Query, page, perPage int, sources ...*registry.DataSource) (senml.Pack, int, error) Query(q Query, sources ...*registry.DataStream) (senml.Pack, int, *time.Time, 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
}