Documentation ¶
Overview ¶
Package registry implements Registry 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 Aggregation
- type Connector
- type DataSource
- type EventListener
- type LevelDBStorage
- func (s *LevelDBStorage) Add(ds DataSource) (DataSource, error)
- func (s *LevelDBStorage) Delete(id string) error
- func (s *LevelDBStorage) Filter(path, op, value string, page, perPage int) ([]DataSource, int, error)
- func (s *LevelDBStorage) FilterOne(path, op, value string) (*DataSource, error)
- func (s *LevelDBStorage) Get(id string) (DataSource, error)
- func (s *LevelDBStorage) GetMany(page, perPage int) ([]DataSource, int, error)
- func (s *LevelDBStorage) Update(id string, ds DataSource) (DataSource, error)
- type MQTTConf
- type MemoryStorage
- func (ms *MemoryStorage) Add(ds DataSource) (DataSource, error)
- func (ms *MemoryStorage) Delete(id string) error
- func (ms *MemoryStorage) Filter(path, op, value string, page, perPage int) ([]DataSource, int, error)
- func (ms *MemoryStorage) FilterOne(path, op, value string) (*DataSource, error)
- func (ms *MemoryStorage) Get(id string) (DataSource, error)
- func (ms *MemoryStorage) GetMany(page, perPage int) ([]DataSource, int, error)
- func (ms *MemoryStorage) Update(id string, ds DataSource) (DataSource, error)
- type Registry
- type RemoteClient
- func (c *RemoteClient) Add(d *DataSource) (string, error)
- func (c *RemoteClient) Delete(id string) error
- func (c *RemoteClient) Filter(path, op, value string) ([]DataSource, error)
- func (c *RemoteClient) FilterOne(path, op, value string) (*DataSource, error)
- func (c *RemoteClient) Get(id string) (*DataSource, error)
- func (c *RemoteClient) GetMany(page int, perPage int) (*Registry, error)
- func (c *RemoteClient) Update(id string, d *DataSource) error
- type Storage
Constants ¶
const ( FTypeOne = "one" FTypeMany = "many" MaxPerPage = 100 )
const ( MEMORY = "memory" LEVELDB = "leveldb" )
Variables ¶
var ( ErrNotFound = errors.New("Datasource Not Found") ErrConflict = errors.New("Conflict") )
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 Aggregation ¶
type Aggregation struct { ID string `json:"id"` // Interval is the aggregation interval Interval string `json:"interval"` // Data is the URL to the data in the Aggregate API Data string `json:"data"` // Aggregates is an array of aggregates calculated on each interval // Valid values: mean, stddev, sum, min, max, median Aggregates []string `json:"aggregates"` // Retention is the retention duration Retention string `json:"retention"` }
Aggregation describes a data aggregatoin for a Data Source
func (*Aggregation) Make ¶
func (a *Aggregation) Make(dsID string)
Generate ID and Data attributes for a given aggregation ID is the checksum of aggregation interval and all its aggregates
type Connector ¶
type Connector struct {
MQTT *MQTTConf `json:"mqtt,omitempty"`
}
Connector describes additional connectors to the Data API
type DataSource ¶
type DataSource struct { // ID is a unique ID of the data source ID string `json:"id"` // URL is the URL of the Data Source in the Registry API URL string `json:"url"` // Data is the URL to the data of this Data Source Data API Data string `json:"data"` // Resource URI (i.e., name in SenML) Resource string `json:"resource"` // Meta is a hash-map with optional meta-information Meta map[string]interface{} `json:"meta"` // Data connector Connector Connector `json:"connector"` // Retention is the retention duration for data Retention string `json:"retention"` // Aggregation is an array of configured aggregations Aggregation []Aggregation `json:"aggregation"` // Type is the values type used in payload Type string `json:"type"` // contains filtered or unexported fields }
DataSource describes a single data source such as a sensor (LinkSmart Resource)
func (DataSource) MarshalJSON ¶ added in v0.5.0
func (ds DataSource) MarshalJSON() ([]byte, error)
MarshalJSON masks sensitive information when using the default marshaller
func (DataSource) MarshalSensitiveJSON ¶ added in v0.5.0
func (ds DataSource) MarshalSensitiveJSON() ([]byte, error)
MarshalSensitiveJSON serializes the datasource including the sensitive information
func (*DataSource) ParsedResource ¶
func (ds *DataSource) ParsedResource() *url.URL
type EventListener ¶ added in v0.6.1
type EventListener interface { CreateHandler(new DataSource) error UpdateHandler(old DataSource, new DataSource) error DeleteHandler(old DataSource) 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 DataSource) (DataSource, error)
func (*LevelDBStorage) Delete ¶ added in v0.6.1
func (s *LevelDBStorage) Delete(id string) error
func (*LevelDBStorage) Filter ¶ added in v0.6.1
func (s *LevelDBStorage) Filter(path, op, value string, page, perPage int) ([]DataSource, int, error)
Filter multiple registrations
func (*LevelDBStorage) FilterOne ¶ added in v0.6.1
func (s *LevelDBStorage) FilterOne(path, op, value string) (*DataSource, error)
Path filtering Filter one registration
func (*LevelDBStorage) Get ¶ added in v0.6.1
func (s *LevelDBStorage) Get(id string) (DataSource, error)
func (*LevelDBStorage) GetMany ¶ added in v0.6.1
func (s *LevelDBStorage) GetMany(page, perPage int) ([]DataSource, int, error)
func (*LevelDBStorage) Update ¶ added in v0.6.1
func (s *LevelDBStorage) Update(id string, ds DataSource) (DataSource, error)
type MQTTConf ¶
type MQTTConf struct { URL string `json:"url"` Topic string `json:"topic"` QoS byte `json:"qos"` 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"` }
MQTT describes a MQTT Connector
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 DataSource) (DataSource, error)
func (*MemoryStorage) Delete ¶ added in v0.6.1
func (ms *MemoryStorage) Delete(id string) error
func (*MemoryStorage) Filter ¶ added in v0.6.1
func (ms *MemoryStorage) Filter(path, op, value string, page, perPage int) ([]DataSource, int, error)
Filter multiple registrations
func (*MemoryStorage) FilterOne ¶ added in v0.6.1
func (ms *MemoryStorage) FilterOne(path, op, value string) (*DataSource, error)
Path filtering Filter one registration
func (*MemoryStorage) Get ¶ added in v0.6.1
func (ms *MemoryStorage) Get(id string) (DataSource, error)
func (*MemoryStorage) GetMany ¶ added in v0.6.1
func (ms *MemoryStorage) GetMany(page, perPage int) ([]DataSource, int, error)
func (*MemoryStorage) Update ¶ added in v0.6.1
func (ms *MemoryStorage) Update(id string, ds DataSource) (DataSource, error)
type Registry ¶
type Registry struct { // URL is the URL of the Registry API URL string `json:"url"` // Entries is an array of Data Sources Entries []DataSource `json:"entries"` // Page is the current page in Entries pagination Page int `json:"page"` // PerPage 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"` }
Registry describes a registry of registered Data Sources
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 *DataSource) (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) ([]DataSource, error)
func (*RemoteClient) FilterOne ¶
func (c *RemoteClient) FilterOne(path, op, value string) (*DataSource, error)
func (*RemoteClient) Get ¶
func (c *RemoteClient) Get(id string) (*DataSource, error)
func (*RemoteClient) GetMany ¶ added in v0.6.1
func (c *RemoteClient) GetMany(page int, perPage int) (*Registry, error)
func (*RemoteClient) Update ¶
func (c *RemoteClient) Update(id string, d *DataSource) error
type Storage ¶
type Storage interface { // CRUD Add(ds DataSource) (DataSource, error) Update(id string, ds DataSource) (DataSource, error) Get(id string) (DataSource, error) Delete(id string) error // Utility functions GetMany(page, perPage int) ([]DataSource, int, error) FilterOne(path, op, value string) (*DataSource, error) Filter(path, op, value string, page, perPage int) ([]DataSource, int, error) // contains filtered or unexported methods }
Storage is an interface of a Registry storage backend
func NewLevelDBStorage ¶
func NewMemoryStorage ¶
func NewMemoryStorage(conf common.RegConf, listeners ...EventListener) Storage