Documentation
¶
Index ¶
- Variables
- func CreateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, ...) (bool, *HorizonDevice, *HorizonDevice)
- func DeleteAgreement(errorhandler ErrorHandler, agreementId string, db *bolt.DB) (bool, *events.ApiAgreementCancelationMessage)
- func DeleteHorizonDevice(removeNode string, block string, em *events.EventStateManager, ...) bool
- func DeletePublicKey(fileName string, config *config.HorizonConfig, errorhandler ErrorHandler) bool
- func FinalizeAttributesSpecifiedInService(defaultRAM int64, sensorURL string, attributes []persistence.Attribute) []persistence.Attribute
- func FindAgreementsForOutput(db *bolt.DB) (map[string]map[string][]persistence.EstablishedAgreement, error)
- func FindAndWrapAttributesForOutput(db *bolt.DB, id string) (map[string][]Attribute, error)
- func FindEventLogsForOutput(db *bolt.DB, all_logs bool, selections map[string][]string) ([]persistence.EventLog, error)
- func FindPublicKeyForOutput(fileName string, config *config.HorizonConfig) (string, error)
- func FindPublicKeysForOutput(config *config.HorizonConfig, verbose bool) (map[string][]interface{}, error)
- func FindServiceConfigForOutput(pm *policy.PolicyManager, db *bolt.DB) (map[string][]MicroserviceConfig, error)
- func GetMicroserviceContainer(dockerEndpoint string, mURL string, mVersion string, mInstanceId string) ([]dockerclient.APIContainers, error)
- func GetWorkloadContainers(dockerEndpoint string, agreementId string) ([]dockerclient.APIContainers, error)
- func InputIsIllegal(str string) (string, error)
- func LogDeviceEvent(db *bolt.DB, severity string, message string, event_code string, ...)
- func LogServiceEvent(db *bolt.DB, severity string, message string, event_code string, ...)
- func MapInputIsIllegal(m map[string]interface{}) (string, string, error)
- func NoOpStateChange(from string, to string) bool
- func UpdateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, db *bolt.DB) (bool, *HorizonDevice, *HorizonDevice)
- func UploadPublicKey(filename string, inBytes []byte, config *config.HorizonConfig, ...) bool
- func ValidStateChange(from string, to string) bool
- func ValidateAndConvertAPIAttribute(errorhandler ErrorHandler, permitEmpty bool, given Attribute) (persistence.Attribute, bool, error)
- type API
- type APIMicroserviceConfig
- type APIUserInputError
- type AllMicroservices
- type AllServices
- type AllWorkloads
- type Attribute
- type AttributeVerifier
- type BadRequestError
- type BlockchainState
- type Configstate
- type ConflictError
- type DuplicateServiceError
- type ErrorHandler
- type EstablishedAgreementsByAgreementCreationTime
- type EstablishedAgreementsByAgreementTerminatedTime
- type EventLogByRecordId
- type HorizonDevice
- type KeyPairSimpleRecord
- type MSMissingVariableConfigError
- type MicroserviceConfig
- type MicroserviceDefById
- type MicroserviceDefByUpgradeStartTime
- type MicroserviceInstanceByCleanupStartTime
- type MicroserviceInstanceByMicroserviceDefId
- type MicroserviceInstanceOutput
- type NotFoundError
- type Service
- type SystemError
Constants ¶
This section is empty.
Variables ¶
var IllegalInputCharRegex = `[^-*+()?&! _\w\d.@,:/\\]`
var Unconfiguring bool
Global "static" field to remember that unconfig is in progress. We can't tell from the configstate in the node object because it eventually gets deleted at the end of unconfiguration.
Functions ¶
func CreateHorizonDevice ¶
func CreateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, getOrg exchange.OrgHandlerWithContext, getPatterns exchange.PatternHandlerWithContext, em *events.EventStateManager, db *bolt.DB) (bool, *HorizonDevice, *HorizonDevice)
Given a demarshalled HorizonDevice object, validate it and save it, returning any errors.
func DeleteAgreement ¶
func DeleteAgreement(errorhandler ErrorHandler, agreementId string, db *bolt.DB) (bool, *events.ApiAgreementCancelationMessage)
func DeleteHorizonDevice ¶
func DeleteHorizonDevice(removeNode string, block string, em *events.EventStateManager, msgQueue chan events.Message, errorhandler ErrorHandler, db *bolt.DB) bool
Handles the DELETE verb on this resource.
func DeletePublicKey ¶
func DeletePublicKey(fileName string, config *config.HorizonConfig, errorhandler ErrorHandler) bool
func FinalizeAttributesSpecifiedInService ¶
func FinalizeAttributesSpecifiedInService(defaultRAM int64, sensorURL string, attributes []persistence.Attribute) []persistence.Attribute
func FindAgreementsForOutput ¶
func FindAgreementsForOutput(db *bolt.DB) (map[string]map[string][]persistence.EstablishedAgreement, error)
func FindAndWrapAttributesForOutput ¶
serializeAttributeForOutput retrieves attributes by url from the DB and then serializes then as JSON, returning a byte array for convenient writing to an HTTP response.
func FindEventLogsForOutput ¶
func FindEventLogsForOutput(db *bolt.DB, all_logs bool, selections map[string][]string) ([]persistence.EventLog, error)
This API returns the event logs saved on the db.
func FindPublicKeyForOutput ¶
func FindPublicKeyForOutput(fileName string, config *config.HorizonConfig) (string, error)
func FindPublicKeysForOutput ¶
func FindPublicKeysForOutput(config *config.HorizonConfig, verbose bool) (map[string][]interface{}, error)
func FindServiceConfigForOutput ¶
func FindServiceConfigForOutput(pm *policy.PolicyManager, db *bolt.DB) (map[string][]MicroserviceConfig, error)
func GetMicroserviceContainer ¶
func GetMicroserviceContainer(dockerEndpoint string, mURL string, mVersion string, mInstanceId string) ([]dockerclient.APIContainers, error)
Get docker container metadata from the docker API for microservice containers
func GetWorkloadContainers ¶
func GetWorkloadContainers(dockerEndpoint string, agreementId string) ([]dockerclient.APIContainers, error)
Get docker container metadata from the docker API for workload containers
func InputIsIllegal ¶
func LogDeviceEvent ¶
func LogServiceEvent ¶
func MapInputIsIllegal ¶
returns: faulty value, msg, error
func NoOpStateChange ¶
func UpdateHorizonDevice ¶
func UpdateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, db *bolt.DB) (bool, *HorizonDevice, *HorizonDevice)
Handles the PATCH verb on this resource. Only the exchange token is updateable.
func UploadPublicKey ¶
func UploadPublicKey(filename string, inBytes []byte, config *config.HorizonConfig, errorhandler ErrorHandler) bool
func ValidStateChange ¶
func ValidateAndConvertAPIAttribute ¶
func ValidateAndConvertAPIAttribute(errorhandler ErrorHandler, permitEmpty bool, given Attribute) (persistence.Attribute, bool, error)
Types ¶
type API ¶
type API struct {
worker.Manager // embedded field
EC *worker.BaseExchangeContext
// contains filtered or unexported fields
}
func NewAPIListener ¶
func NewAPIListener(name string, config *config.HorizonConfig, db *bolt.DB, pm *policy.PolicyManager) *API
func (*API) GetExchangeId ¶
A local implementation of the ExchangeContext interface because the API object is not an anax worker.
func (*API) GetExchangeToken ¶
func (*API) GetExchangeURL ¶
func (*API) GetHTTPFactory ¶
func (a *API) GetHTTPFactory() *config.HTTPClientFactory
type APIMicroserviceConfig ¶
type APIMicroserviceConfig struct {
SensorUrl string `json:"sensor_url"` // uniquely identifying
SensorOrg string `json:"sensor_org"` // The org that holds the ms definition
SensorVersion string `json:"sensor_version"` // added for ms split. It is only used for microsevice. If it is omitted, old behavior is assumed.
AutoUpgrade bool `json:"auto_upgrade"` // added for ms split. The default is true. If the sensor (microservice) should be automatically upgraded when new versions become available.
ActiveUpgrade bool `json:"active_upgrade"` // added for ms split. The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements terminated before making upgrade.
Attributes []interface{} `json:"attributes"`
}
type APIUserInputError ¶
APIUserInputError is for problems found with input path variables or input bodies. The Input field is flexible; could be a field name or other. Note: the info in this field is intended to be consumed by humans, either API consumers or developers of the UI. Add enum codes if these are to be evaluated in frontend code.
func NewAPIUserInputError ¶
func NewAPIUserInputError(err string, input string) *APIUserInputError
func (APIUserInputError) Error ¶
func (e APIUserInputError) Error() string
type AllMicroservices ¶
type AllMicroservices struct {
Config []MicroserviceConfig `json:"config"` // the microservice configurations
Instances map[string][]interface{} `json:"instances"` // the microservice instances that are running
Definitions map[string][]interface{} `json:"definitions"` // the definitions of microservices from the exchange
}
The output format for GET microservice
func NewMicroserviceOutput ¶
func NewMicroserviceOutput() *AllMicroservices
type AllServices ¶
type AllServices struct {
Config []MicroserviceConfig `json:"config"` // the service configurations
Instances map[string][]interface{} `json:"instances"` // the mservice instances that are running
Definitions map[string][]interface{} `json:"definitions"` // the definitions of services from the exchange
}
The output format for GET service
func FindServicesForOutput ¶
func FindServicesForOutput(pm *policy.PolicyManager, db *bolt.DB, config *config.HorizonConfig) (*AllServices, error)
This API returns everything we know about services configured to and running on an edge node. It includes service definition metadata that is cached from the exchange, userInput variable config for each service, running containers for each service, and the state of each service as it is being managed by anax.
func NewServiceOutput ¶
func NewServiceOutput() *AllServices
type AllWorkloads ¶
type AllWorkloads struct {
Containers *[]dockerclient.APIContainers `json:"containers"` // the docker info for a running container
}
The output format for GET workload
func NewWorkloadOutput ¶
func NewWorkloadOutput() *AllWorkloads
type Attribute ¶
type Attribute struct {
Id *string `json:"id"`
Type *string `json:"type"`
SensorUrls *[]string `json:"sensor_urls"`
Label *string `json:"label"`
Publishable *bool `json:"publishable"`
HostOnly *bool `json:"host_only"`
Mappings *map[string]interface{} `json:"mappings"`
}
func NewAttribute ¶
type AttributeVerifier ¶
type AttributeVerifier func(attr persistence.Attribute) (bool, error)
AttributeVerifier returns true if there is a handled inputError (one that caused a write to the http responsewriter) and error if there is a system processing problem
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
Bad Requests are expected, since they can occur as the result of incorrect usage of the API.
func NewBadRequestError ¶
func NewBadRequestError(err string) *BadRequestError
func (BadRequestError) Error ¶
func (e BadRequestError) Error() string
type BlockchainState ¶
type BlockchainState struct {
// contains filtered or unexported fields
}
type Configstate ¶
type Configstate struct {
State *string `json:"state"`
LastUpdateTime *uint64 `json:"last_update_time,omitempty"`
}
func FindConfigstateForOutput ¶
func FindConfigstateForOutput(db *bolt.DB) (*Configstate, error)
func UpdateConfigstate ¶
func UpdateConfigstate(cfg *Configstate, errorhandler ErrorHandler, getPatterns exchange.PatternHandler, resolveService exchange.ServiceResolverHandler, getService exchange.ServiceHandler, db *bolt.DB, config *config.HorizonConfig) (bool, *Configstate, []*events.PolicyCreatedMessage)
Given a demarshalled Configstate object, validate it and save, returning any errors.
func (*Configstate) String ¶
func (c *Configstate) String() string
type ConflictError ¶
type ConflictError struct {
// contains filtered or unexported fields
}
Conflict Errors are expected, since they can occur as the result of incorrect usage of the API.
func NewConflictError ¶
func NewConflictError(err string) *ConflictError
func (ConflictError) Error ¶
func (e ConflictError) Error() string
type DuplicateServiceError ¶
type DuplicateServiceError struct {
Err string `json:"error"`
Input string `json:"input,omitempty"`
}
DuplicateServiceError occurs when a microservice configuration is attempted for a service that has already been configured.
func NewDuplicateServiceError ¶
func NewDuplicateServiceError(err string, input string) *DuplicateServiceError
func (DuplicateServiceError) Error ¶
func (e DuplicateServiceError) Error() string
type ErrorHandler ¶
This function type is used to enable plug replaceable error handlers within the API implementation so that business logic can be tested independently from the HTTP transport that is used to access the API.
func GetHTTPErrorHandler ¶
func GetHTTPErrorHandler(w http.ResponseWriter) ErrorHandler
Use this function to obtain an error handler that writes errors to the HTTP response.
func GetPassThroughErrorHandler ¶
func GetPassThroughErrorHandler(passthruErr *error) ErrorHandler
Use this function to obtain an error handler that simply passes the error through itself back to caller. This is done by modifying the error variable passed to this function.
type EstablishedAgreementsByAgreementCreationTime ¶
type EstablishedAgreementsByAgreementCreationTime []persistence.EstablishedAgreement
Functions and types that plug into the go sorting feature
func (EstablishedAgreementsByAgreementCreationTime) Len ¶
func (s EstablishedAgreementsByAgreementCreationTime) Len() int
func (EstablishedAgreementsByAgreementCreationTime) Less ¶
func (s EstablishedAgreementsByAgreementCreationTime) Less(i, j int) bool
func (EstablishedAgreementsByAgreementCreationTime) Swap ¶
func (s EstablishedAgreementsByAgreementCreationTime) Swap(i, j int)
type EstablishedAgreementsByAgreementTerminatedTime ¶
type EstablishedAgreementsByAgreementTerminatedTime []persistence.EstablishedAgreement
func (EstablishedAgreementsByAgreementTerminatedTime) Len ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Len() int
func (EstablishedAgreementsByAgreementTerminatedTime) Less ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Less(i, j int) bool
func (EstablishedAgreementsByAgreementTerminatedTime) Swap ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Swap(i, j int)
type EventLogByRecordId ¶
type EventLogByRecordId []persistence.EventLog
func (EventLogByRecordId) Len ¶
func (s EventLogByRecordId) Len() int
func (EventLogByRecordId) Less ¶
func (s EventLogByRecordId) Less(i, j int) bool
func (EventLogByRecordId) Swap ¶
func (s EventLogByRecordId) Swap(i, j int)
type HorizonDevice ¶
type HorizonDevice struct {
Id *string `json:"id"`
Org *string `json:"organization"`
Pattern *string `json:"pattern"` // a simple name, not prefixed with the org
Name *string `json:"name,omitempty"`
Token *string `json:"token,omitempty"`
TokenLastValidTime *uint64 `json:"token_last_valid_time,omitempty"`
TokenValid *bool `json:"token_valid,omitempty"`
HA *bool `json:"ha,omitempty"`
Config *Configstate `json:"configstate,omitempty"`
}
func ConvertFromPersistentHorizonDevice ¶
func ConvertFromPersistentHorizonDevice(pDevice *persistence.ExchangeDevice) *HorizonDevice
This is a type conversion function but note that the token field within the persistent is explicitly omitted so that it's not exposed in the API.
func FindHorizonDeviceForOutput ¶
func FindHorizonDeviceForOutput(db *bolt.DB) (*HorizonDevice, error)
func (HorizonDevice) String ¶
func (h HorizonDevice) String() string
type KeyPairSimpleRecord ¶
type KeyPairSimpleRecord struct {
// embedded
listkeys.KeyPairSimple
ID string `json:"id"`
}
type MSMissingVariableConfigError ¶
type MSMissingVariableConfigError struct {
Err string `json:"error"`
Input string `json:"input,omitempty"`
}
MSMissingVariableConfigError is for problems found with microservice configuration where the microservice definition requires 1 or more input variables to be set but 1 or more of those variables has not been set.
func NewMSMissingVariableConfigError ¶
func NewMSMissingVariableConfigError(err string, input string) *MSMissingVariableConfigError
func (MSMissingVariableConfigError) Error ¶
func (e MSMissingVariableConfigError) Error() string
type MicroserviceConfig ¶
type MicroserviceConfig struct {
SensorUrl string `json:"sensor_url"` // uniquely identifying
SensorOrg string `json:"sensor_org"` // The org that holds the ms definition
SensorVersion string `json:"sensor_version"` // added for ms split. It is only used for microsevice. If it is omitted, old behavior is assumed.
AutoUpgrade bool `json:"auto_upgrade"` // added for ms split. The default is true. If the sensor (microservice) should be automatically upgraded when new versions become available.
ActiveUpgrade bool `json:"active_upgrade"` // added for ms split. The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements terminated before making upgrade.
Attributes []persistence.Attribute `json:"attributes"`
}
The output format for microservice config
func NewMicroserviceConfig ¶
func NewMicroserviceConfig(url string, org string, version string) *MicroserviceConfig
type MicroserviceDefById ¶
type MicroserviceDefById []interface{}
func (MicroserviceDefById) Len ¶
func (s MicroserviceDefById) Len() int
func (MicroserviceDefById) Less ¶
func (s MicroserviceDefById) Less(i, j int) bool
func (MicroserviceDefById) Swap ¶
func (s MicroserviceDefById) Swap(i, j int)
type MicroserviceDefByUpgradeStartTime ¶
type MicroserviceDefByUpgradeStartTime []interface{}
func (MicroserviceDefByUpgradeStartTime) Len ¶
func (s MicroserviceDefByUpgradeStartTime) Len() int
func (MicroserviceDefByUpgradeStartTime) Less ¶
func (s MicroserviceDefByUpgradeStartTime) Less(i, j int) bool
func (MicroserviceDefByUpgradeStartTime) Swap ¶
func (s MicroserviceDefByUpgradeStartTime) Swap(i, j int)
type MicroserviceInstanceByCleanupStartTime ¶
type MicroserviceInstanceByCleanupStartTime []interface{}
func (MicroserviceInstanceByCleanupStartTime) Len ¶
func (s MicroserviceInstanceByCleanupStartTime) Len() int
func (MicroserviceInstanceByCleanupStartTime) Less ¶
func (s MicroserviceInstanceByCleanupStartTime) Less(i, j int) bool
func (MicroserviceInstanceByCleanupStartTime) Swap ¶
func (s MicroserviceInstanceByCleanupStartTime) Swap(i, j int)
type MicroserviceInstanceByMicroserviceDefId ¶
type MicroserviceInstanceByMicroserviceDefId []interface{}
func (MicroserviceInstanceByMicroserviceDefId) Len ¶
func (s MicroserviceInstanceByMicroserviceDefId) Len() int
func (MicroserviceInstanceByMicroserviceDefId) Less ¶
func (s MicroserviceInstanceByMicroserviceDefId) Less(i, j int) bool
func (MicroserviceInstanceByMicroserviceDefId) Swap ¶
func (s MicroserviceInstanceByMicroserviceDefId) Swap(i, j int)
type MicroserviceInstanceOutput ¶
type MicroserviceInstanceOutput struct {
persistence.MicroserviceInstance // an embedded field
Containers *[]dockerclient.APIContainers `json:"containers"` // the docker info for a running container
}
The output format for microservice instances
func NewAgreementServiceInstanceOutput ¶
func NewAgreementServiceInstanceOutput(ag *persistence.EstablishedAgreement, containers *[]dockerclient.APIContainers) *MicroserviceInstanceOutput
func NewMicroserviceInstanceOutput ¶
func NewMicroserviceInstanceOutput(mi persistence.MicroserviceInstance, containers *[]dockerclient.APIContainers) *MicroserviceInstanceOutput
type NotFoundError ¶
Not Found errors are expected, since they can occur as the result of incorrect usage of the API.
func NewNotFoundError ¶
func NewNotFoundError(err string, input string) *NotFoundError
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Service ¶
type Service struct {
Url *string `json:"url"` // The URL of the service definition.
Org *string `json:"organization"` // The org that holds the service definition.
Name *string `json:"name"` // Optional, may not be uniquely identifying.
Arch *string `json:"arch"` // The arch of the service to be configured, could be a synonym.
VersionRange *string `json:"versionRange"` // The version range that the configuration applies to.
AutoUpgrade *bool `json:"auto_upgrade"` // The default is true. If the service should be automatically upgraded when a new version becomes available.
ActiveUpgrade *bool `json:"active_upgrade"` // The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements to terminate before upgrading.
Attributes *[]Attribute `json:"attributes"`
}
uses pointers for members b/c it allows nil-checking at deserialization; !Important!: the json field names here must not change w/out changing the error messages returned from the API, they are not programmatically determined
func CreateService ¶
func CreateService(service *Service, errorhandler ErrorHandler, getPatterns exchange.PatternHandler, resolveService exchange.ServiceResolverHandler, getService exchange.ServiceHandler, db *bolt.DB, config *config.HorizonConfig, from_user bool) (bool, *Service, *events.PolicyCreatedMessage)
Given a demarshalled Service object, validate it and save it, returning any errors.
func NewService ¶
Constructor used to create service objects for programmatic creation of services.
type SystemError ¶
type SystemError struct {
// contains filtered or unexported fields
}
System Errors are generally unexpected, infrastructural problems that just need to be reported out to the caller.
func NewSystemError ¶
func NewSystemError(err string) *SystemError
func (SystemError) Error ¶
func (e SystemError) Error() string
Source Files
¶
- api.go
- api_agreement.go
- api_attribute.go
- api_eventlog.go
- api_node.go
- api_publickey.go
- api_service.go
- api_status.go
- api_token_random.go
- container.go
- errors.go
- input.go
- input_validation.go
- output.go
- path_agreement.go
- path_attributes.go
- path_eventlog.go
- path_node.go
- path_node_configstate.go
- path_publickey.go
- path_service.go
- path_service_config.go