Documentation ¶
Overview ¶
Package registry implements DataStreamList API
Index ¶
- Constants
- Variables
- func ErrType(err, e error) bool
- func SupportedBackends(name string) bool
- type API
- func (api *API) Create(w http.ResponseWriter, r *http.Request)
- func (api *API) Delete(w http.ResponseWriter, r *http.Request)
- func (api *API) Filter(w http.ResponseWriter, r *http.Request)
- func (api *API) Index(w http.ResponseWriter, r *http.Request)
- func (api *API) Retrieve(w http.ResponseWriter, r *http.Request)
- func (api *API) Update(w http.ResponseWriter, r *http.Request)
- type DataStream
- type DataStreamList
- type EventListener
- type LevelDBStorage
- func (s *LevelDBStorage) Add(ds DataStream) (*DataStream, error)
- func (s *LevelDBStorage) Delete(name string) error
- func (s *LevelDBStorage) Filter(path, op, value string, page, perPage int) ([]DataStream, int, error)
- func (s *LevelDBStorage) FilterOne(path, op, value string) (*DataStream, error)
- func (s *LevelDBStorage) Get(id string) (*DataStream, error)
- func (s *LevelDBStorage) GetMany(page, perPage int) ([]DataStream, int, error)
- func (s *LevelDBStorage) Update(name string, ds DataStream) (*DataStream, error)
- type MQTTSource
- type MemoryStorage
- func (ms *MemoryStorage) Add(ds DataStream) (*DataStream, error)
- func (ms *MemoryStorage) Delete(name string) error
- func (ms *MemoryStorage) Filter(path, op, value string, page, perPage int) ([]DataStream, int, error)
- func (ms *MemoryStorage) FilterOne(path, op, value string) (*DataStream, error)
- func (ms *MemoryStorage) Get(id string) (*DataStream, error)
- func (ms *MemoryStorage) GetMany(page, perPage int) ([]DataStream, int, error)
- func (ms *MemoryStorage) Update(id string, ds DataStream) (*DataStream, error)
- type RemoteClient
- func (c *RemoteClient) Add(d *DataStream) (string, error)
- func (c *RemoteClient) Delete(id string) error
- func (c *RemoteClient) Filter(path, op, value string) ([]DataStream, error)
- func (c *RemoteClient) FilterOne(path, op, value string) (*DataStream, error)
- func (c *RemoteClient) Get(id string) (*DataStream, error)
- func (c *RemoteClient) GetMany(page int, perPage int) (*DataStreamList, error)
- func (c *RemoteClient) Update(id string, d *DataStream) error
- type SeriesSource
- type Source
- type SourceType
- type Storage
- type StreamType
Constants ¶
const ( MqttType = "MQTT" SeriesType = "Series" )
const ( FTypeOne = "one" FTypeMany = "many" MaxPerPage = 100 )
const ( MEMORY = "memory" LEVELDB = "leveldb" )
Variables ¶
Functions ¶
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
}
RESTful HTTP API
func (*API) Create ¶ added in v0.6.1
func (api *API) Create(w http.ResponseWriter, r *http.Request)
Create is a handler for creating a new DataSource
func (*API) Delete ¶ added in v0.6.1
func (api *API) Delete(w http.ResponseWriter, r *http.Request)
Delete is a handler for deleting the given DataSource Expected parameters: id
func (*API) Filter ¶ added in v0.6.1
func (api *API) Filter(w http.ResponseWriter, r *http.Request)
Filter is a handler for registry filtering API Expected parameters: path, type, op, value
func (*API) Index ¶ added in v0.6.1
func (api *API) Index(w http.ResponseWriter, r *http.Request)
Index is a handler for the registry index
type DataStream ¶
type DataStream struct { // Name is the BrokerURL of the DataStreamList API Name string `json:"name"` //Source of the Data streams Source Source `json:"source,omitempty"` //Function to be performed on the Data streams Function string `json:"function,omitempty"` //Type of the data (eg: string, float, bool, data) Type StreamType `json:"dataType"` //Unit of the data Unit string `json:"unit,omitempty"` // Meta is a hash-map with optional meta-information Meta map[string]interface{} `json:"meta"` // Retention Retention struct { //minimum requirement for the retention Min string `json:"min,omitempty"` //maximum requirement for the retention. This is useful for enforcing the data privacy Max string `json:"max,omitempty"` } `json:"retain,omitempty"` // contains filtered or unexported fields }
A Datastream describes a stored stream of data
func (DataStream) MarshalJSON ¶
func (ds DataStream) MarshalJSON() ([]byte, error)
MarshalJSON masks sensitive information when using the default marshaller
func (DataStream) MarshalSensitiveJSON ¶
func (ds DataStream) MarshalSensitiveJSON() ([]byte, error)
MarshalSensitiveJSON serializes the datasource including the sensitive information
type DataStreamList ¶
type DataStreamList struct { // BrokerURL is the BrokerURL of the DataStreamList API URL string `json:"url"` // Entries is an array of Data streams Streams []DataStream `json:"streams"` // Page is the current page in Entries pagination Page int `json:"page"` // MaxEntries is the results per page in Entries pagination PerPage int `json:"per_page"` // Total is the total #of pages in Entries pagination Total int `json:"total"` }
DataStreamList describes a registry of registered Data streams
type EventListener ¶ added in v0.6.1
type EventListener interface { CreateHandler(new DataStream) error UpdateHandler(old DataStream, new DataStream) error DeleteHandler(old DataStream) error }
EventListener is implemented by storage modules and connectors which need to react to changes in the registry
type LevelDBStorage ¶
type LevelDBStorage struct {
// contains filtered or unexported fields
}
LevelDB storage
func (*LevelDBStorage) Add ¶ added in v0.6.1
func (s *LevelDBStorage) Add(ds DataStream) (*DataStream, error)
func (*LevelDBStorage) Delete ¶ added in v0.6.1
func (s *LevelDBStorage) Delete(name string) error
func (*LevelDBStorage) Filter ¶ added in v0.6.1
func (s *LevelDBStorage) Filter(path, op, value string, page, perPage int) ([]DataStream, int, error)
Filter multiple registrations
func (*LevelDBStorage) FilterOne ¶ added in v0.6.1
func (s *LevelDBStorage) FilterOne(path, op, value string) (*DataStream, error)
Path filtering Filter one registration
func (*LevelDBStorage) Get ¶ added in v0.6.1
func (s *LevelDBStorage) Get(id string) (*DataStream, error)
func (*LevelDBStorage) GetMany ¶ added in v0.6.1
func (s *LevelDBStorage) GetMany(page, perPage int) ([]DataStream, int, error)
func (*LevelDBStorage) Update ¶ added in v0.6.1
func (s *LevelDBStorage) Update(name string, ds DataStream) (*DataStream, error)
type MQTTSource ¶
type MQTTSource struct { //complete BrokerURL including protocols BrokerURL string `json:"url"` //Topic to subscribe for the datasource Topic string `json:"topic"` //QoS of subscription QoS byte `json:"qos,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` CaFile string `json:"caFile,omitempty"` CertFile string `json:"certFile,omitempty"` KeyFile string `json:"keyFile,omitempty"` Insecure bool `json:"insecure,omitempty"` }
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
In-memory storage
func (*MemoryStorage) Add ¶ added in v0.6.1
func (ms *MemoryStorage) Add(ds DataStream) (*DataStream, error)
func (*MemoryStorage) Delete ¶ added in v0.6.1
func (ms *MemoryStorage) Delete(name string) error
func (*MemoryStorage) Filter ¶ added in v0.6.1
func (ms *MemoryStorage) Filter(path, op, value string, page, perPage int) ([]DataStream, int, error)
Filter multiple registrations
func (*MemoryStorage) FilterOne ¶ added in v0.6.1
func (ms *MemoryStorage) FilterOne(path, op, value string) (*DataStream, error)
Path filtering Filter one registration
func (*MemoryStorage) Get ¶ added in v0.6.1
func (ms *MemoryStorage) Get(id string) (*DataStream, error)
func (*MemoryStorage) GetMany ¶ added in v0.6.1
func (ms *MemoryStorage) GetMany(page, perPage int) ([]DataStream, int, error)
func (*MemoryStorage) Update ¶ added in v0.6.1
func (ms *MemoryStorage) Update(id string, ds DataStream) (*DataStream, error)
type RemoteClient ¶
type RemoteClient struct {
// contains filtered or unexported fields
}
func NewRemoteClient ¶
func NewRemoteClient(serverEndpoint string, ticket *obtainer.Client) (*RemoteClient, error)
func (*RemoteClient) Add ¶
func (c *RemoteClient) Add(d *DataStream) (string, error)
func (*RemoteClient) Delete ¶
func (c *RemoteClient) Delete(id string) error
func (*RemoteClient) Filter ¶ added in v0.6.1
func (c *RemoteClient) Filter(path, op, value string) ([]DataStream, error)
func (*RemoteClient) FilterOne ¶
func (c *RemoteClient) FilterOne(path, op, value string) (*DataStream, error)
func (*RemoteClient) Get ¶
func (c *RemoteClient) Get(id string) (*DataStream, error)
func (*RemoteClient) GetMany ¶ added in v0.6.1
func (c *RemoteClient) GetMany(page int, perPage int) (*DataStreamList, error)
func (*RemoteClient) Update ¶
func (c *RemoteClient) Update(id string, d *DataStream) error
type SeriesSource ¶
type SeriesSource struct { //name of the series URL string `json:name` }
type Source ¶
type Source struct { //type of the source //This can be either MQTT or a series element itself SrcType SourceType `json:"type,omitempty"` *MQTTSource *SeriesSource }
Source describes a single Data stream such as a sensor (LinkSmart Resource)
type SourceType ¶
type SourceType string
type Storage ¶
type Storage interface { // CRUD Add(ds DataStream) (*DataStream, error) Update(name string, ds DataStream) (*DataStream, error) Get(name string) (*DataStream, error) Delete(name string) error // Utility functions GetMany(page, perPage int) ([]DataStream, int, error) FilterOne(path, op, value string) (*DataStream, error) Filter(path, op, value string, page, perPage int) ([]DataStream, int, error) // contains filtered or unexported methods }
Storage is an interface of a DataStreamList storage backend
func NewLevelDBStorage ¶
func NewMemoryStorage ¶
func NewMemoryStorage(conf common.RegConf, listeners ...EventListener) Storage
type StreamType ¶
type StreamType int
StreamType represents the type of a specific stream
const ( Float StreamType = iota String Bool Data )
func (StreamType) MarshalJSON ¶
func (s StreamType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (StreamType) String ¶
func (s StreamType) String() string
func (*StreamType) UnmarshalJSON ¶
func (s *StreamType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value