Documentation ¶
Overview ¶
Package registry implements Registry API
Index ¶
- Constants
- Variables
- func ErrType(err, e error) bool
- type Aggregation
- type Client
- type Connector
- type DataSource
- type DummyRegistryStorage
- type HTTPAPI
- func (regAPI *HTTPAPI) Create(w http.ResponseWriter, r *http.Request)
- func (regAPI *HTTPAPI) Delete(w http.ResponseWriter, r *http.Request)
- func (regAPI *HTTPAPI) Filter(w http.ResponseWriter, r *http.Request)
- func (regAPI *HTTPAPI) Index(w http.ResponseWriter, r *http.Request)
- func (regAPI *HTTPAPI) Retrieve(w http.ResponseWriter, r *http.Request)
- func (regAPI *HTTPAPI) Update(w http.ResponseWriter, r *http.Request)
- type LevelDBStorage
- type LocalClient
- func (c *LocalClient) Add(r DataSource) (DataSource, error)
- func (c *LocalClient) Delete(id string) error
- func (c *LocalClient) FindDataSource(path, op, value string) (*DataSource, error)
- func (c *LocalClient) FindDataSources(path, op, value string, page, perPage int) ([]DataSource, int, error)
- func (c *LocalClient) Get(id string) (DataSource, error)
- func (c *LocalClient) GetDataSources(page int, perPage int) ([]DataSource, int, error)
- func (c *LocalClient) Update(id string, r DataSource) (DataSource, error)
- type MQTTConf
- type MemoryStorage
- type Registry
- type RemoteClient
- func (c *RemoteClient) Add(d *DataSource) (string, error)
- func (c *RemoteClient) Delete(id string) error
- func (c *RemoteClient) FilterMany(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) Index(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 )
Variables ¶
var ( ErrNotFound = errors.New("Datasource Not Found") ErrConflict = errors.New("Conflict") )
Functions ¶
Types ¶
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 Client ¶
type Client interface { // CRUD Add(d DataSource) (DataSource, error) Update(id string, d DataSource) (DataSource, error) Get(id string) (DataSource, error) Delete(id string) error // Returns a slice of DataSources given: // page - page in the collection // perPage - number of entries per page GetDataSources(page, perPage int) ([]DataSource, int, error) // Returns a single DataSource given: path, operation, value FindDataSource(path, op, value string) (*DataSource, error) // Returns a slice of DataSources given: path, operation, value, page, perPage FindDataSources(path, op, value string, page, perPage int) ([]DataSource, int, error) }
Client is an interface of a Registry client
func NewLocalClient ¶
NewLocalClient returns a new LocalClient given a storage
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 is the URL identifying the corresponding // LinkSmart Resource (e.g., @id in the Resource Catalog) 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"` // Format is the MIME type of the payload Format string `json:"format"` // 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 DummyRegistryStorage ¶
type DummyRegistryStorage struct{}
type HTTPAPI ¶
type HTTPAPI struct {
// contains filtered or unexported fields
}
RESTful HTTP API
func (*HTTPAPI) Create ¶
func (regAPI *HTTPAPI) Create(w http.ResponseWriter, r *http.Request)
Create is a handler for creating a new DataSource
func (*HTTPAPI) Delete ¶
func (regAPI *HTTPAPI) Delete(w http.ResponseWriter, r *http.Request)
Delete is a handler for deleting the given DataSource Expected parameters: id
func (*HTTPAPI) Filter ¶
func (regAPI *HTTPAPI) Filter(w http.ResponseWriter, r *http.Request)
Filter is a handler for registry filtering API Expected parameters: path, type, op, value
func (*HTTPAPI) Index ¶
func (regAPI *HTTPAPI) Index(w http.ResponseWriter, r *http.Request)
Index is a handler for the registry index
type LevelDBStorage ¶
type LevelDBStorage struct {
// contains filtered or unexported fields
}
LevelDB storage
type LocalClient ¶
type LocalClient struct {
// contains filtered or unexported fields
}
LocalClient implements local registry client
func (*LocalClient) Add ¶
func (c *LocalClient) Add(r DataSource) (DataSource, error)
Add creates a DataSource
func (*LocalClient) Delete ¶
func (c *LocalClient) Delete(id string) error
Delete deletes a DataSource
func (*LocalClient) FindDataSource ¶
func (c *LocalClient) FindDataSource(path, op, value string) (*DataSource, error)
FindDataSource returns a single DataSource given: path, operation, value
func (*LocalClient) FindDataSources ¶
func (c *LocalClient) FindDataSources(path, op, value string, page, perPage int) ([]DataSource, int, error)
FindDataSources returns a slice of DataSources given: path, operation, value, page, perPage
func (*LocalClient) Get ¶
func (c *LocalClient) Get(id string) (DataSource, error)
Get retrieves a DataSource
func (*LocalClient) GetDataSources ¶
func (c *LocalClient) GetDataSources(page int, perPage int) ([]DataSource, int, error)
GetDataSources returns a slice of DataSources given: page - page in the collection perPage - number of entries per page
func (*LocalClient) Update ¶
func (c *LocalClient) Update(id string, r DataSource) (DataSource, error)
Update updates a DataSource
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
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) FilterMany ¶
func (c *RemoteClient) FilterMany(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) Update ¶
func (c *RemoteClient) Update(id string, d *DataSource) error
type Storage ¶
type Storage interface {
// contains filtered or unexported methods
}
Storage is an interface of a Registry storage backend
func NewLevelDBStorage ¶
func NewMemoryStorage ¶
func NewMemoryStorage(conf common.RegConf) (Storage, *chan common.Notification)