Documentation ¶
Index ¶
- Constants
- func ChkErr(err error)
- func ChkErrFatal(err error)
- func Debug(msg string)
- func Err(msg string)
- func GetHttpsCredentials() string
- func GetStoreURLFromDsHref(href string) (string, error)
- func Info(msg string)
- func IsActuator(dsm DataSource) bool
- func IsFunc(dsm DataSource) bool
- func NewDataboxHTTPsAPI() *http.Client
- func NewDataboxHTTPsAPIWithPaths(cmRootCaPath string) *http.Client
- func OutputDebug(state bool)
- func Warn(msg string)
- type AggregationType
- type ArbiterClient
- func (arb *ArbiterClient) GetRootDataSourceCatalogue() (HypercatRoot, error)
- func (arb *ArbiterClient) GrantComponentPermission()
- func (arb *ArbiterClient) GrantContainerPermissions(permissions ContainerPermissions) error
- func (arb *ArbiterClient) InvalidateCache(href string, method string, caveats string) error
- func (arb *ArbiterClient) RegesterDataboxComponent(name string, tokenString string, databoxType DataboxType) error
- func (arb *ArbiterClient) RemoveDataboxComponent()
- func (arb *ArbiterClient) RequestDeligatedToken(scrHost string, href string, method string, caveat string) ([]byte, error)
- func (arb *ArbiterClient) RequestToken(href string, method string, caveat string) ([]byte, error)
- func (arb *ArbiterClient) RevokeComponentPermission()
- type ContainerManagerOptions
- type ContainerPermissions
- type CoreStoreClient
- type DataSource
- type DataSourceMetadata
- type DataboxType
- type DevMount
- type DriverProvides
- type Export
- type ExportDestination
- type ExportWhitelist
- type ExternalWhitelist
- type Filter
- type FilterType
- type Func
- type FuncHandler
- type FuncRequest
- type FuncResponse
- type FuncStatus
- type HypercatItem
- type HypercatRoot
- type KVStore
- func (kvj *KVStore) Delete(dataSourceID string, key string) error
- func (kvj *KVStore) DeleteAll(dataSourceID string) error
- func (kvj *KVStore) ListKeys(dataSourceID string) ([]string, error)
- func (kvj *KVStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
- func (kvj *KVStore) ObserveKey(dataSourceID string, key string) (<-chan ObserveResponse, error)
- func (kvj *KVStore) Read(dataSourceID string, key string) ([]byte, error)
- func (kvj *KVStore) Write(dataSourceID string, key string, payload []byte) error
- type LogEntries
- type Logger
- type Logs
- type Macaroon
- type Manifest
- type NotifyResponse
- type ObserveResponse
- type RelValPair
- type RelValPairBool
- type Repository
- type ResourceRequirements
- type Route
- type SLA
- type StoreContentType
- type StoreType
- type TSBlobStore
- func (tbs *TSBlobStore) Earliest(dataSourceID string) ([]byte, error)
- func (tbs *TSBlobStore) FirstN(dataSourceID string, n int) ([]byte, error)
- func (tbs *TSBlobStore) LastN(dataSourceID string, n int) ([]byte, error)
- func (tbs *TSBlobStore) Latest(dataSourceID string) ([]byte, error)
- func (tbs *TSBlobStore) Length(dataSourceID string) (int, error)
- func (tbs *TSBlobStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
- func (tbs *TSBlobStore) Range(dataSourceID string, formTimeStamp int64, toTimeStamp int64) ([]byte, error)
- func (tbs *TSBlobStore) Since(dataSourceID string, sinceTimeStamp int64) ([]byte, error)
- func (tbs *TSBlobStore) Write(dataSourceID string, payload []byte) error
- func (tbs *TSBlobStore) WriteAt(dataSourceID string, timstamp int64, payload []byte) error
- type TSStore
- func (tsc TSStore) Earliest(dataSourceID string) ([]byte, error)
- func (tsc TSStore) FirstN(dataSourceID string, n int, opt TimeSeriesQueryOptions) ([]byte, error)
- func (tsc TSStore) LastN(dataSourceID string, n int, opt TimeSeriesQueryOptions) ([]byte, error)
- func (tsc TSStore) Latest(dataSourceID string) ([]byte, error)
- func (tsc TSStore) Length(dataSourceID string) (int, error)
- func (tsc TSStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
- func (tsc TSStore) Range(dataSourceID string, formTimeStamp int64, toTimeStamp int64, ...) ([]byte, error)
- func (tsc TSStore) Since(dataSourceID string, sinceTimeStamp int64, opt TimeSeriesQueryOptions) ([]byte, error)
- func (tsc TSStore) Write(dataSourceID string, payload []byte) error
- func (tsc TSStore) WriteAt(dataSourceID string, timstamp int64, payload []byte) error
- type TimeSeriesQueryOptions
Constants ¶
const ( Equals FilterType = "equals" Contains FilterType = "contains" Sum AggregationType = "sum" Count AggregationType = "count" Min AggregationType = "min" Max AggregationType = "max" Mean AggregationType = "mean" Median AggregationType = "median" StandardDeviation AggregationType = "sd" )
Allowed values for FilterType and AggregationFunction
const DefaultArbiterKeyPath = "/run/secrets/ARBITER_TOKEN"
const DefaultArbiterURI = "tcp://arbiter:4444"
const DefaultHTTPSCertPath = "/run/secrets/DATABOX.pem"
DefaultHTTPSCertPath is the defaut loaction where apps and drivers can find the https certivicats needed to offer a secure UI
const DefaultHTTPSRootCertPath = "/run/secrets/DATABOX_ROOT_CA"
DefaultHTTPSRootCertPath contins the Public key of this databoxes Root certificate needed to verify requests to other components (used in )
const DefaultStorePublicKeyPath = "/run/secrets/ZMQ_PUBLIC_KEY"
Variables ¶
This section is empty.
Functions ¶
func ChkErrFatal ¶
func ChkErrFatal(err error)
func GetHttpsCredentials ¶
func GetHttpsCredentials() string
GetHttpsCredentials Returns a string containing the HTTPS credentials to pass to https server when offering an https server. These are read form /run/secrets/DATABOX.pem and are generated by the container-manger at run time.
func GetStoreURLFromDsHref ¶
GetStoreURLFromDsHref extracts the base store url from the href provied in the hypercat descriptions.
func IsActuator ¶ added in v0.5.3
func IsActuator(dsm DataSource) bool
func IsFunc ¶ added in v0.5.3
func IsFunc(dsm DataSource) bool
func NewDataboxHTTPsAPI ¶
func OutputDebug ¶ added in v0.5.9
func OutputDebug(state bool)
Types ¶
type AggregationType ¶
type AggregationType string
type ArbiterClient ¶
type ArbiterClient struct { ArbiterToken string ZestC zest.ZestClient // contains filtered or unexported fields }
func NewArbiterClient ¶
func NewArbiterClient(arbiterTokenPath string, zmqPublicKeyPath string, arbiterZMQURI string) (*ArbiterClient, error)
NewArbiterClient returns an arbiter client for use by components that require conunication with the arbiter
func (*ArbiterClient) GetRootDataSourceCatalogue ¶
func (arb *ArbiterClient) GetRootDataSourceCatalogue() (HypercatRoot, error)
GetRootDataSourceCatalogue is used by the container manager to access the Root hypercat catalogue
func (*ArbiterClient) GrantComponentPermission ¶
func (arb *ArbiterClient) GrantComponentPermission()
func (*ArbiterClient) GrantContainerPermissions ¶
func (arb *ArbiterClient) GrantContainerPermissions(permissions ContainerPermissions) error
GrantContainerPermissions allows the container manager to grant permissions to an app or driver on a registered store.
func (*ArbiterClient) InvalidateCache ¶
func (arb *ArbiterClient) InvalidateCache(href string, method string, caveats string) error
InvalidateCache can be used to remove a token from the arbiterClient cache. This is done automatically if the token is rejected.
func (*ArbiterClient) RegesterDataboxComponent ¶
func (arb *ArbiterClient) RegesterDataboxComponent(name string, tokenString string, databoxType DataboxType) error
RegesterDataboxComponent allows the container manager to register a new app, driver or store with the arbiter
func (*ArbiterClient) RemoveDataboxComponent ¶
func (arb *ArbiterClient) RemoveDataboxComponent()
func (*ArbiterClient) RequestDeligatedToken ¶ added in v0.6.7
func (arb *ArbiterClient) RequestDeligatedToken(scrHost string, href string, method string, caveat string) ([]byte, error)
RequestDeligatedToken is used to request a token from the arbiter for another component scrHost is the hostname to hume the permissions are deligated
func (*ArbiterClient) RequestToken ¶
RequestToken is used internally to request a token from the arbiter for the current host
func (*ArbiterClient) RevokeComponentPermission ¶
func (arb *ArbiterClient) RevokeComponentPermission()
type ContainerManagerOptions ¶
type ContainerManagerOptions struct { Version string SwarmAdvertiseAddress string DefaultRegistryHost string DefaultRegistry string DefaultAppStore string DefaultStoreImage string ContainerManagerImage string CoreUIImage string ArbiterImage string CoreNetworkImage string CoreNetworkRelayImage string AppServerImage string ExportServiceImage string EnableDebugLogging bool ClearSLAs bool OverridePasword string Hostname string InternalIPs []string ExternalIP string HostPath string Arch string //current architecture used to chose the correct docker images "" for x86 or "arm64v8" for arm64v8 ;-) DevMounts []DevMount }
ContainerManagerOptions is used to configure the Container Manager
type ContainerPermissions ¶
type CoreStoreClient ¶
type CoreStoreClient struct { ZestC zest.ZestClient Arbiter *ArbiterClient ZEndpoint string DEndpoint string KVJSON *KVStore KVText *KVStore KVBin *KVStore TSBlobJSON *TSBlobStore TSBlobText *TSBlobStore TSBlobBin *TSBlobStore TSJSON *TSStore FUNC *Func EXPORT *Export }
func NewCoreStoreClient ¶
func NewCoreStoreClient(arbiterClient *ArbiterClient, zmqPublicKeyPath string, storeEndPoint string, enableLogging bool) *CoreStoreClient
func NewDefaultCoreStoreClient ¶
func NewDefaultCoreStoreClient(storeEndPoint string) *CoreStoreClient
func (*CoreStoreClient) GetStoreDataSourceCatalogue ¶
func (csc *CoreStoreClient) GetStoreDataSourceCatalogue(href string) (HypercatRoot, error)
func (*CoreStoreClient) RegisterDatasource ¶
func (csc *CoreStoreClient) RegisterDatasource(metadata DataSourceMetadata) error
RegisterDatasource is used by apps and drivers to register datasource in stores they own.
type DataSource ¶
type DataSource struct { Type string `json:"type"` Required bool `json:"required"` Name string `json:"name"` Clientid string `json:"clientid"` Granularities []string `json:"granularities"` Hypercat HypercatItem `json:"hypercat"` Min int `json:"min"` Max int `json:"max"` NotifyOfNewSources bool `json:"allow-notification-of-new-sources"` }
type DataSourceMetadata ¶
type DataSourceMetadata struct { Description string //required ContentType StoreContentType //required Vendor string //required DataSourceType string //required DataSourceID string //required StoreType StoreType //required IsActuator bool IsFunc bool Unit string Location string }
func HypercatToDataSourceMetadata ¶
func HypercatToDataSourceMetadata(hypercatDataSourceDescription string) (DataSourceMetadata, string, error)
HypercatToDataSourceMetadata is a helper function to convert the hypercat description of a datasource to a DataSourceMetadata instance Also returns the store url for this data source.
type DataboxType ¶
type DataboxType string
const ( DataboxTypeApp DataboxType = "app" DataboxTypeDriver DataboxType = "driver" DataboxTypeStore DataboxType = "store" )
type DriverProvides ¶ added in v0.6.1
type ExportDestination ¶ added in v0.6.1
type ExportDestination struct {
Destination string `json:"destination"`
}
type ExportWhitelist ¶
type ExternalWhitelist ¶
type Filter ¶
type Filter struct { TagName string FilterType FilterType Value string }
Filter types to hold the required data to apply the filtering functions of the structured json API
type FilterType ¶
type FilterType string
type Func ¶ added in v0.5.2
type Func struct {
// contains filtered or unexported fields
}
Func the databox function call, drivers can regiter functions with the Register method. Apps can request access to these in their manifests and call them using the call method Call.
func (Func) Call ¶ added in v0.5.2
func (f Func) Call(functionName string, payload []byte, contentType StoreContentType) (<-chan FuncResponse, error)
Call is used by clients to invoke functions by name. The result of the function call is returned via the FuncResponse chan only one result will be retuned then the channel will be closed.
func (*Func) Register ¶ added in v0.5.2
func (f *Func) Register(vendor string, functionName string, contentType StoreContentType, handler FuncHandler) error
Register is used to advertise available functions to other components it adds an entry into your stores Hypercat catalogue and starts listening for requests. Received requests are routed to the FuncHandler registed for the function.
type FuncHandler ¶ added in v0.5.2
type FuncHandler = func(contentType StoreContentType, payload []byte) ([]byte, error)
FuncHandler s are executed when a request is received on the request endpoint of registered functions
type FuncRequest ¶ added in v0.5.2
type FuncRequest struct { TimestampMS int64 Path string ContentType StoreContentType Payload []byte }
FuncRequest holds the datareturned from a function call
type FuncResponse ¶ added in v0.5.2
type FuncResponse struct { Status FuncStatus Response []byte }
FuncResponse describes the response that must be returned by a FuncHandler
type FuncStatus ¶ added in v0.5.2
type FuncStatus int
FuncStatus is an int representing the status of a returned function
const FuncStatusError FuncStatus = 99
const FuncStatusFailedToGetToken FuncStatus = 97
const FuncStatusInvalidPayload FuncStatus = 98
const FuncStatusOK FuncStatus = 0
type HypercatItem ¶
type HypercatItem struct { ItemMetadata []interface{} `json:"item-metadata"` Href string `json:"href"` }
type HypercatRoot ¶
type HypercatRoot struct { CatalogueMetadata []RelValPair `json:"catalogue-metadata"` Items []HypercatItem `json:"items"` }
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
func (*KVStore) Observe ¶
func (kvj *KVStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
func (*KVStore) ObserveKey ¶
func (kvj *KVStore) ObserveKey(dataSourceID string, key string) (<-chan ObserveResponse, error)
type LogEntries ¶
type Logger ¶
type Logger struct {
Store *CoreStoreClient
}
func (Logger) GetLastNLogEntries ¶
func (Logger) GetLastNLogEntriesRaw ¶
type Logs ¶
type Logs []LogEntries
type Manifest ¶
type Manifest struct { ManifestVersion int `json:"manifest-version"` // Name string `json:"name"` // DockerImage string `json:"docker-image"` // Optional: docker image name e.g my-cool-app (-amd64 or -amd64v8 will be added depending on the platform) defaults to Name from above DockerRegistry string `json:"docker-registry"` // Optional: docker registry e.g myDockerRegistry defaults to datboxsystems DockerImageTag string `json:"docker-image-tag"` // Optional: docker image tag e.g latest or v0.5.1 etc defaults to the running version of databox DataboxType DataboxType `json:"databox-type"` // Version string `json:"version"` // this is databox version e.g 0.3.1 Description string `json:"description"` // free text description Author string `json:"author"` // Tosh Brown <Anthony.Brown@nottingham.ac.uk> License string `json:"license"` // Software licence Tags []string `json:"tags"` // search tags Homepage string `json:"homepage"` // homepage url Repository Repository `json:"repository"` // git repo where the core can be found DataSources []DataSource `json:"datasources"` // ExportWhitelists []ExportWhitelist `json:"export-whitelist"` // "export-whitelist": [{"url": "https://export.amar.io/","description": "Exports the data to amar.io"}], ExternalWhitelist []ExternalWhitelist `json:"external-whitelist"` // "external-whitelist": [{"urls": ["https://api.twitter.com/"],"description": "reason displayed to user for requiring access"}] ResourceRequirements ResourceRequirements `json:"resource-requirements"` //this is where you can requests a store "store":"core-store" is the only valid option for now. DisplayName string `json:"displayName"` StoreURL string `json:"storeUrl"` Provides []DriverProvides `json:"provides"` }
type NotifyResponse ¶ added in v0.5.2
type NotifyResponse struct { TimestampMS int64 ContentType StoreContentType Data []byte }
type ObserveResponse ¶
OBSERVE RESPONSE
type RelValPair ¶
type RelValPairBool ¶
type Repository ¶
type ResourceRequirements ¶
type ResourceRequirements struct {
Store string `json:"store"`
}
type SLA ¶
type SLA struct { ManifestVersion int `json:"manifest-version"` // Name string `json:"name"` // container name e.g core-store DockerImage string `json:"docker-image"` // Optional: docker image name e.g my-cool-app (-amd64 or -amd64v8 will be added depending on the platform) defaults to Name from above DockerRegistry string `json:"docker-registry"` // Optional: docker registry e.g myDockerRegistry defaults to datboxsystems DockerImageTag string `json:"docker-image-tag"` // Optional: docker image tag e.g latest or v0.5.1 etc defaults to the running version of databox DataboxType DataboxType `json:"databox-type"` // App or driver Version string `json:"version"` // this is databox version e.g 0.3.1 Description string `json:"description"` // free text description Author string `json:"author"` // Tosh Brown <Anthony.Brown@nottingham.ac.uk> License string `json:"license"` // Software licence Tags []string `json:"tags"` // search tags Homepage string `json:"homepage"` // homepage url Repository Repository `json:"repository"` // git repo where the core can be found Datasources []DataSource `json:"datasources"` // ExportWhitelists []ExportWhitelist `json:"export-whitelist"` // ExternalWhitelist []ExternalWhitelist `json:"external-whitelist"` // ResourceRequirements ResourceRequirements `json:"resource-requirements"` //this is where you can requests a store "store":"core-store" is the only valid option for now. DisplayName string `json:"displayName"` // StoreURL string `json:"storeUrl"` // }
type StoreContentType ¶
type StoreContentType string
const ContentTypeBINARY StoreContentType = "BINARY"
const ContentTypeJSON StoreContentType = "JSON"
const ContentTypeTEXT StoreContentType = "TEXT"
type StoreType ¶
type StoreType string
const StoreTypeFunc StoreType = "notification/request"
const StoreTypeKV StoreType = "kv"
const StoreTypeTS StoreType = "ts"
const StoreTypeTSBlob StoreType = "ts/blob"
type TSBlobStore ¶
type TSBlobStore struct {
// contains filtered or unexported fields
}
func (*TSBlobStore) Earliest ¶
func (tbs *TSBlobStore) Earliest(dataSourceID string) ([]byte, error)
Earliest will retrieve the first entry stored at the requested datasource ID return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (*TSBlobStore) FirstN ¶
func (tbs *TSBlobStore) FirstN(dataSourceID string, n int) ([]byte, error)
FirstN will retrieve the first N entries stored at the requested datasource ID return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (*TSBlobStore) LastN ¶
func (tbs *TSBlobStore) LastN(dataSourceID string, n int) ([]byte, error)
LastN will retrieve the last N entries stored at the requested datasource ID return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (*TSBlobStore) Latest ¶
func (tbs *TSBlobStore) Latest(dataSourceID string) ([]byte, error)
TSBlobLatest will retrieve the last entry stored at the requested datasource ID return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (*TSBlobStore) Length ¶
func (tbs *TSBlobStore) Length(dataSourceID string) (int, error)
TSBlobLength returns then number of items stored in the timeseries
func (*TSBlobStore) Observe ¶
func (tbs *TSBlobStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
Observe allows you to get notifications when a new value is written by a driver the returned chan receives chan ObserveResponse the data value og which contins json of the form {"TimestampMS":213123123,"Json":byte[]}
func (*TSBlobStore) Range ¶
func (tbs *TSBlobStore) Range(dataSourceID string, formTimeStamp int64, toTimeStamp int64) ([]byte, error)
Range will retrieve all entries between formTimeStamp and toTimeStamp timestamp in ms since unix epoch return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (*TSBlobStore) Since ¶
func (tbs *TSBlobStore) Since(dataSourceID string, sinceTimeStamp int64) ([]byte, error)
Since will retrieve all entries since the requested timestamp (ms since unix epoch) return data is a byte array contingin of the format {"timestamp":213123123,"data":[data-written-by-driver]}
type TSStore ¶
type TSStore struct {
// contains filtered or unexported fields
}
func (TSStore) Earliest ¶
Earliest will retrieve the first entry stored at the requested datasource ID return data is a JSON object of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (TSStore) FirstN ¶
FirstN will retrieve the first N entries stored at the requested datasource ID return data is an array of JSON objects of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (TSStore) LastN ¶
LastN will retrieve the last N entries stored at the requested datasource ID return data is an array of JSON objects of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (TSStore) Latest ¶
Latest will retrieve the last entry stored at the requested datasource ID return data is a JSON object of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (TSStore) Observe ¶
func (tsc TSStore) Observe(dataSourceID string) (<-chan ObserveResponse, error)
func (TSStore) Range ¶
func (tsc TSStore) Range(dataSourceID string, formTimeStamp int64, toTimeStamp int64, opt TimeSeriesQueryOptions) ([]byte, error)
Range will retrieve all entries between formTimeStamp and toTimeStamp timestamp in ms since unix epoch return data is a JSON object of the format {"timestamp":213123123,"data":[data-written-by-driver]}
func (TSStore) Since ¶
func (tsc TSStore) Since(dataSourceID string, sinceTimeStamp int64, opt TimeSeriesQueryOptions) ([]byte, error)
Since will retrieve all entries since the requested timestamp (ms since unix epoch) return data is a JSON object of the format {"timestamp":213123123,"data":[data-written-by-driver]}
type TimeSeriesQueryOptions ¶
type TimeSeriesQueryOptions struct { AggregationFunction AggregationType Filter *Filter }
TimeSeriesQueryOptions describes the query options for the structured json API