exchange

package
v0.0.0-...-4862416 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const IMPL_PACKAGE_CONTAINER = "dockerRegistry"
View Source
const IMPL_PACKAGE_DISCRIMINATOR = "storeType"

This type is used to describe the package that implements the service. A package is a generic idea that can be realized in many forms. Initially a docker container is the only supported form. The schema for this type is left wide open. There is 1 required key in the map; "storeType" which is used to discriminate what other keys should be there. The valid values for storeType are "container" and "imageServer". The map could be completely empty if the docker container image in the deployment string is being used as the "package".

View Source
const IMPL_PACKAGE_IMAGESERVER = "imageServer"
View Source
const MS_SHARING_MODE_EXCLUSIVE = "exclusive"

This is the structure of the object returned on a GET /service. microservice sharing mode

View Source
const MS_SHARING_MODE_MULTIPLE = "multiple"
View Source
const MS_SHARING_MODE_SINGLE = "single" // deprecated, use singleton instead. but leave it here for backward compatibility
View Source
const MS_SHARING_MODE_SINGLETON = "singleton"
View Source
const PATTERN = "pattern"
View Source
const SERVICE = "service"

Variables

This section is empty.

Functions

func ConvertAgreementProtocol

func ConvertAgreementProtocol(p *Pattern, pol *policy.Policy)

func ConvertChoice

func ConvertChoice(wl WorkloadChoice, url string, org string, arch string, pol *policy.Policy)

func ConvertCommon

func ConvertCommon(p *Pattern, patternId string, dv DataVerification, nodeh NodeHealth, pol *policy.Policy)

Common conversion function calls

func ConvertDataVerify

func ConvertDataVerify(dv DataVerification, pol *policy.Policy)

func ConvertNodeHealth

func ConvertNodeHealth(nodeh NodeHealth, pol *policy.Policy)

func ConvertToPolicies

func ConvertToPolicies(patternId string, p *Pattern) ([]*policy.Policy, error)

Convert a pattern to a list of policy objects. Each pattern contains 1 or more workloads or services, which will each be translated to a policy.

func ConvertToString

func ConvertToString(a []string) string

func DeconstructExchangeMessage

func DeconstructExchangeMessage(encryptedMessage []byte, receiverPrivateKey *rsa.PrivateKey) ([]byte, *rsa.PublicKey, error)

func DeleteKeys

func DeleteKeys(keyPath string) error

func DemarshalPublicKey

func DemarshalPublicKey(serializedKey []byte) (*rsa.PublicKey, error)

Helper function that uses the PKI X.509 library to deserialize an RSA key.

func GetExchangeVersion

func GetExchangeVersion(httpClientFactory *config.HTTPClientFactory, exchangeUrl string, id string, token string) (string, error)

func GetId

func GetId(id string) string

func GetKeys

func GetKeys(keyPath string) (*rsa.PublicKey, *rsa.PrivateKey, error)

func GetObjectSigningKeys

func GetObjectSigningKeys(ec ExchangeContext, oType string, oURL string, oOrg string, oVersion string, oArch string) (map[string]string, error)

This function gets the pattern/service signing key names and their contents. The oType is one of PATTERN, or SERVICE defined in the beginning of this file. When oType is PATTERN, the oURL is the pattern name and oVersion and oArch are ignored.

func GetOrg

func GetOrg(id string) string

Helper functions for dealing with exchangeIds that are already prefixed with the org name and then "/".

func GetPatterns

func GetPatterns(httpClientFactory *config.HTTPClientFactory, org string, pattern string, exURL string, id string, token string) (map[string]Pattern, error)

Get all the pattern metadata for a specific organization, and pattern if specified.

func HasKeys

func HasKeys() bool

func Heartbeat

func Heartbeat(h *http.Client, url string, id string, token string) error

func InvokeExchange

func InvokeExchange(httpClient *http.Client, method string, url string, user string, pw string, params interface{}, resp *interface{}) (error, error)

This function is used to invoke an exchange API For GET, the given resp parameter will be untouched when http returns code 404.

func MarshalPublicKey

func MarshalPublicKey(key *rsa.PublicKey) ([]byte, error)

Helper function that uses the PKI X.509 library to serialize an RSA key.

Types

type Agbot

type Agbot struct {
	Token         string `json:"token"`
	Name          string `json:"name"`
	Owner         string `json:"owner"`
	MsgEndPoint   string `json:"msgEndPoint"`
	LastHeartbeat string `json:"lastHeartbeat"`
	PublicKey     []byte `json:"publicKey"`
}

func (Agbot) ShortString

func (a Agbot) ShortString() string

func (Agbot) String

func (a Agbot) String() string

type AgbotAgreement

type AgbotAgreement struct {
	Service     WorkloadAgreement `json:"service,omitempty"`
	State       string            `json:"state"`
	LastUpdated string            `json:"lastUpdated"`
}

func (AgbotAgreement) String

func (a AgbotAgreement) String() string

type AgbotMessage

type AgbotMessage struct {
	MsgId        int    `json:"msgId"`
	DeviceId     string `json:"nodeId"`
	DevicePubKey []byte `json:"nodePubKey"`
	Message      []byte `json:"message"`
	TimeSent     string `json:"timeSent"`
	TimeExpires  string `json:"timeExpires"`
}

func (AgbotMessage) String

func (a AgbotMessage) String() string

type AgreementObject

type AgreementObject struct {
}

type AgreementProtocol

type AgreementProtocol struct {
	Name            string         `json:"name,omitempty"`            // The name of the agreement protocol to be used
	ProtocolVersion int            `json:"protocolVersion,omitempty"` // The max protocol version supported
	Blockchains     BlockchainList `json:"blockchains,omitempty"`     // The blockchain to be used if the protocol requires one.
}

type AllAgbotAgreementsResponse

type AllAgbotAgreementsResponse struct {
	Agreements map[string]AgbotAgreement `json:"agreements"`
	LastIndex  int                       `json:"lastIndex"`
}

func (AllAgbotAgreementsResponse) String

type AllDeviceAgreementsResponse

type AllDeviceAgreementsResponse struct {
	Agreements map[string]DeviceAgreement `json:"agreements"`
	LastIndex  int                        `json:"lastIndex"`
}

func (AllDeviceAgreementsResponse) String

type Blockchain

type Blockchain struct {
	Type string `json:"type,omitempty"`         // The type of blockchain
	Name string `json:"name,omitempty"`         // The name of the blockchain instance in the exchange,it is specific to the value of the type
	Org  string `json:"organization,omitempty"` // The organization that owns the blockchain definition
}

type BlockchainList

type BlockchainList []Blockchain

type DataVerification

type DataVerification struct {
	Enabled     bool   `json:"enabled,omitempty"`    // Whether or not data verification is enabled
	URL         string `json:"URL,omitempty"`        // The URL to be used for data receipt verification
	URLUser     string `json:"user,omitempty"`       // The user id to use when calling the verification URL
	URLPassword string `json:"password,omitempty"`   // The password to use when calling the verification URL
	Interval    int    `json:"interval,omitempty"`   // The number of seconds to check for data before deciding there isnt any data
	CheckRate   int    `json:"check_rate,omitempty"` // The number of seconds between checks for valid data being received
	Metering    Meter  `json:"metering,omitempty"`   // The metering configuration
}

type Device

type Device struct {
	Token              string          `json:"token"`
	Name               string          `json:"name"`
	Owner              string          `json:"owner"`
	Pattern            string          `json:"pattern"`
	RegisteredServices []Microservice  `json:"registeredServices"`
	MsgEndPoint        string          `json:"msgEndPoint"`
	SoftwareVersions   SoftwareVersion `json:"softwareVersions"`
	LastHeartbeat      string          `json:"lastHeartbeat"`
	PublicKey          []byte          `json:"publicKey"`
}

Structs and types for interacting with the device (node) object in the exchange

func GetExchangeDevice

func GetExchangeDevice(httpClientFactory *config.HTTPClientFactory, deviceId string, deviceToken string, exchangeUrl string) (*Device, error)

type DeviceAgreement

type DeviceAgreement struct {
	Service          []MSAgreementState `json:"services"`
	State            string             `json:"state"`
	AgreementService WorkloadAgreement  `json:"agrService"`
	LastUpdated      string             `json:"lastUpdated"`
}

func (DeviceAgreement) String

func (a DeviceAgreement) String() string

type DeviceHandler

type DeviceHandler func(id string, token string) (*Device, error)

A handler for getting the device information from the exchange

func GetHTTPDeviceHandler

func GetHTTPDeviceHandler(ec ExchangeContext) DeviceHandler

type DeviceMessage

type DeviceMessage struct {
	MsgId       int    `json:"msgId"`
	AgbotId     string `json:"agbotId"`
	AgbotPubKey []byte `json:"agbotPubKey"`
	Message     []byte `json:"message"`
	TimeSent    string `json:"timeSent"`
}

func (DeviceMessage) String

func (d DeviceMessage) String() string

type EncryptedSymmetricValues

type EncryptedSymmetricValues []byte

type EncryptedWrappedMessage

type EncryptedWrappedMessage []byte

type ExchangeContext

type ExchangeContext interface {
	GetExchangeId() string
	GetExchangeToken() string
	GetExchangeURL() string
	GetHTTPFactory() *config.HTTPClientFactory
}

type ExchangeMessage

type ExchangeMessage struct {
	WrappedMessage  EncryptedWrappedMessage  `json:"wrappedMessage"`
	SymmetricValues EncryptedSymmetricValues `json:"symmetricValues"`
}

func ConstructExchangeMessage

func ConstructExchangeMessage(message []byte, senderPublicKey *rsa.PublicKey, senderPrivateKey *rsa.PrivateKey, receiverPublicKey *rsa.PublicKey) (*ExchangeMessage, error)

func (ExchangeMessage) String

func (self ExchangeMessage) String() string

type ExchangeMessageTarget

type ExchangeMessageTarget struct {
	ReceiverExchangeId     string // in the form org/id
	ReceiverPublicKeyObj   *rsa.PublicKey
	ReceiverPublicKeyBytes []byte
	ReceiverMsgEndPoint    string
}

func CreateMessageTarget

func CreateMessageTarget(receiverId string, receiverPubKey *rsa.PublicKey, receiverPubKeySerialized []byte, receiverMessageEndpoint string) (*ExchangeMessageTarget, error)

type ExchangeMessageWorker

type ExchangeMessageWorker struct {
	worker.BaseWorker // embedded field
	// contains filtered or unexported fields
}

func NewExchangeMessageWorker

func NewExchangeMessageWorker(name string, cfg *config.HorizonConfig, db *bolt.DB) *ExchangeMessageWorker

func (*ExchangeMessageWorker) Initialize

func (w *ExchangeMessageWorker) Initialize() bool

func (*ExchangeMessageWorker) Messages

func (w *ExchangeMessageWorker) Messages() chan events.Message

func (*ExchangeMessageWorker) NewEvent

func (w *ExchangeMessageWorker) NewEvent(incoming events.Message)

func (*ExchangeMessageWorker) NoWorkHandler

func (w *ExchangeMessageWorker) NoWorkHandler()

type GetAgbotMessageResponse

type GetAgbotMessageResponse struct {
	Messages  []AgbotMessage `json:"messages"`
	LastIndex int            `json:"lastIndex"`
}

type GetAgbotsPatternsResponse

type GetAgbotsPatternsResponse struct {
	Patterns map[string]ServedPattern `json:"patterns"`
}

type GetAgbotsResponse

type GetAgbotsResponse struct {
	Agbots    map[string]Agbot `json:"agbots"`
	LastIndex int              `json:"lastIndex"`
}

type GetDeviceMessageResponse

type GetDeviceMessageResponse struct {
	Messages  []DeviceMessage `json:"messages"`
	LastIndex int             `json:"lastIndex"`
}

type GetDevicesResponse

type GetDevicesResponse struct {
	Devices   map[string]Device `json:"nodes"`
	LastIndex int               `json:"lastIndex"`
}

type GetOrganizationResponse

type GetOrganizationResponse struct {
	Orgs      map[string]Organization `json:"orgs"`
	LastIndex int                     `json:"lastIndex"`
}

type GetPatternResponse

type GetPatternResponse struct {
	Patterns  map[string]Pattern `json:"patterns,omitempty"` // map of all defined patterns
	LastIndex int                `json:"lastIndex.omitempty"`
}

type GetServicesResponse

type GetServicesResponse struct {
	Services  map[string]ServiceDefinition `json:"services"`
	LastIndex int                          `json:"lastIndex"`
}

func (*GetServicesResponse) ShortString

func (w *GetServicesResponse) ShortString() string

type HardwareRequirement

type HardwareRequirement map[string]interface{}

This type is used to abstract the various edge node hardware requirements. The schema is left wide open.

func (HardwareRequirement) String

func (h HardwareRequirement) String() string

type ImageDockerAuth

type ImageDockerAuth struct {
	DockAuthId  int    `json:"dockAuthId"`
	Registry    string `json:"registry"`
	UserName    string `json:"username"`
	Token       string `json:"token"`
	LastUpdated string `json:"lastUpdated"`
}

func GetServiceDockerAuths

func GetServiceDockerAuths(ec ExchangeContext, url string, org string, version string, arch string) ([]ImageDockerAuth, error)

This function gets the image docker auths for a service.

func GetServiceDockerAuthsWithId

func GetServiceDockerAuthsWithId(ec ExchangeContext, service_id string) ([]ImageDockerAuth, error)

This function gets the image docker auths for the service by the given service id

func (ImageDockerAuth) String

func (s ImageDockerAuth) String() string

type ImplementationPackage

type ImplementationPackage map[string]interface{}

func (ImplementationPackage) String

func (i ImplementationPackage) String() string

type MSAgreementState

type MSAgreementState struct {
	Org string `json:"orgid"`
	URL string `json:"url"`
}

type MSProp

type MSProp struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	PropType string `json:"propType"`
	Op       string `json:"op"`
}

Structs used to invoke the exchange API

func ConvertPropertyToExchangeFormat

func ConvertPropertyToExchangeFormat(prop *policy.Property) (*MSProp, error)

func (MSProp) String

func (p MSProp) String() string

type Meter

type Meter struct {
	Tokens                uint64 `json:"tokens,omitempty"`                // The number of tokens per time_unit
	PerTimeUnit           string `json:"per_time_unit,omitempty"`         // The per time units: min, hour and day are supported
	NotificationIntervalS int    `json:"notification_interval,omitempty"` // The number of seconds between metering notifications
}

type Microservice

type Microservice struct {
	Url           string   `json:"url"`
	Properties    []MSProp `json:"properties"`
	NumAgreements int      `json:"numAgreements"`
	Policy        string   `json:"policy"`
}

func (Microservice) ShortString

func (m Microservice) ShortString() string

func (Microservice) String

func (m Microservice) String() string

type NodeHealth

type NodeHealth struct {
	MissingHBInterval    int `json:"missing_heartbeat_interval,omitempty"` // How long a heartbeat can be missing until it is considered missing (in seconds)
	CheckAgreementStatus int `json:"check_agreement_status,omitempty"`     // How often to check that the node agreement entry still exists in the exchange (in seconds)
}

type NodeHealthStatus

type NodeHealthStatus struct {
	Nodes map[string]NodeInfo `json:"nodes"`
}

func GetNodeHealthStatus

func GetNodeHealthStatus(httpClientFactory *config.HTTPClientFactory, pattern string, org string, nodeOrgs []string, lastCallTime string, exURL string, id string, token string) (*NodeHealthStatus, error)

Return the current status of nodes in a given pattern. This function can return nil and no error if the exchange has no updated status to return.

type NodeHealthStatusRequest

type NodeHealthStatusRequest struct {
	NodeOrgIds []string `json:"nodeOrgids,omitempty"`
	LastCall   string   `json:"lastTime"`
}

type NodeInfo

type NodeInfo struct {
	LastHeartbeat string                     `json:"lastHeartbeat"`
	Agreements    map[string]AgreementObject `json:"agreements"`
}

func (NodeInfo) String

func (n NodeInfo) String() string

type ObjectSigningKeysHandler

type ObjectSigningKeysHandler func(oType, oUrl string, oOrg string, oVersion string, oArch string) (map[string]string, error)

a handler for getting microservice keys from the exchange

func GetHTTPObjectSigningKeysHandler

func GetHTTPObjectSigningKeysHandler(ec ExchangeContext) ObjectSigningKeysHandler

type OrgHandler

type OrgHandler func(org string) (*Organization, error)

A handler for querying the exchange for an organization.

func GetHTTPExchangeOrgHandler

func GetHTTPExchangeOrgHandler(ec ExchangeContext) OrgHandler

type OrgHandlerWithContext

type OrgHandlerWithContext func(org string, id string, token string) (*Organization, error)

A handler for querying the exchange for an org when the caller doesnt have exchange identity at the time of creating the handler, but can supply the exchange context when it's time to make the call. Only used by the API package when trying to register an edge device.

func GetHTTPExchangeOrgHandlerWithContext

func GetHTTPExchangeOrgHandlerWithContext(cfg *config.HorizonConfig) OrgHandlerWithContext

type Organization

type Organization struct {
	Label       string `json:"label"`
	Description string `json:"description"`
	LastUpdated string `json:"lastUpdated"`
}

Functions and types for working with organizations in the exchange

func GetOrganization

func GetOrganization(httpClientFactory *config.HTTPClientFactory, org string, exURL string, id string, token string) (*Organization, error)

Get the metadata for a specific organization.

type PatchAgbotPublicKey

type PatchAgbotPublicKey struct {
	PublicKey []byte `json:"publicKey"`
}

func CreateAgbotPublicKeyPatch

func CreateAgbotPublicKeyPatch(keyPath string) *PatchAgbotPublicKey

This function creates the device registration message body.

func CreatePatchDeviceKey

func CreatePatchDeviceKey() *PatchAgbotPublicKey

This function creates the device registration complete message body.

type Pattern

type Pattern struct {
	Owner              string              `json:"owner"`
	Label              string              `json:"label"`
	Description        string              `json:"description"`
	Public             bool                `json:"public"`
	Services           []ServiceReference  `json:"services"`
	AgreementProtocols []AgreementProtocol `json:"agreementProtocols"`
}

func (Pattern) ShortString

func (w Pattern) ShortString() string

func (Pattern) String

func (w Pattern) String() string

type PatternHandler

type PatternHandler func(org string, pattern string) (map[string]Pattern, error)

A handler for querying the exchange for patterns.

func GetHTTPExchangePatternHandler

func GetHTTPExchangePatternHandler(ec ExchangeContext) PatternHandler

type PatternHandlerWithContext

type PatternHandlerWithContext func(org string, pattern string, id string, token string) (map[string]Pattern, error)

A handler for querying the exchange for patterns when the caller doesnt have exchange identity at the time of creating the handler, but can supply the exchange context when it's time to make the call. Only used by the API package when trying to register an edge device.

func GetHTTPExchangePatternHandlerWithContext

func GetHTTPExchangePatternHandlerWithContext(cfg *config.HorizonConfig) PatternHandlerWithContext

type PostDeviceResponse

type PostDeviceResponse struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

type PostMessage

type PostMessage struct {
	Message []byte `json:"message"`
	TTL     int    `json:"ttl"`
}

func CreatePostMessage

func CreatePostMessage(msg []byte, ttl int) *PostMessage

func (PostMessage) String

func (p PostMessage) String() string

type PutAgbotAgreementState

type PutAgbotAgreementState struct {
	Service WorkloadAgreement `json:"service,omitempty"`
	State   string            `json:"state"`
}

type PutAgreementState

type PutAgreementState struct {
	State            string             `json:"state"`
	Services         []MSAgreementState `json:"services,omitempty"`
	AgreementService WorkloadAgreement  `json:"agreementService,omitempty"`
}

func (PutAgreementState) String

func (p PutAgreementState) String() string

type PutDeviceHandler

type PutDeviceHandler func(deviceId string, deviceToken string, pdr *PutDeviceRequest) (*PutDeviceResponse, error)

A handler for modifying the device information on the exchange

func GetHTTPPutDeviceHandler

func GetHTTPPutDeviceHandler(ec ExchangeContext) PutDeviceHandler

type PutDeviceRequest

type PutDeviceRequest struct {
	Token              string          `json:"token"`
	Name               string          `json:"name"`
	Pattern            string          `json:"pattern"`
	RegisteredServices []Microservice  `json:"registeredServices"`
	MsgEndPoint        string          `json:"msgEndPoint"`
	SoftwareVersions   SoftwareVersion `json:"softwareVersions"`
	PublicKey          []byte          `json:"publicKey"`
}

func CreateDevicePut

func CreateDevicePut(token string, name string) *PutDeviceRequest

This function creates the device registration message body.

func (PutDeviceRequest) ShortString

func (p PutDeviceRequest) ShortString() string

func (PutDeviceRequest) String

func (p PutDeviceRequest) String() string

type PutDeviceResponse

type PutDeviceResponse map[string]string

func PutExchangeDevice

func PutExchangeDevice(httpClientFactory *config.HTTPClientFactory, deviceId string, deviceToken string, exchangeUrl string, pdr *PutDeviceRequest) (*PutDeviceResponse, error)

modify the the device

type SearchExchangeMSRequest

type SearchExchangeMSRequest struct {
	DesiredServices    []Microservice `json:"desiredServices"`
	SecondsStale       int            `json:"secondsStale"`
	PropertiesToReturn []string       `json:"propertiesToReturn"`
	StartIndex         int            `json:"startIndex"`
	NumEntries         int            `json:"numEntries"`
}

structs and types for working with microservice based exchange searches

func CreateSearchMSRequest

func CreateSearchMSRequest() *SearchExchangeMSRequest

This function creates the exchange search message body.

func (SearchExchangeMSRequest) String

func (a SearchExchangeMSRequest) String() string

type SearchExchangeMSResponse

type SearchExchangeMSResponse struct {
	Devices   []SearchResultDevice `json:"nodes"`
	LastIndex int                  `json:"lastIndex"`
}

func (SearchExchangeMSResponse) String

func (r SearchExchangeMSResponse) String() string

type SearchExchangePatternRequest

type SearchExchangePatternRequest struct {
	ServiceURL   string   `json:"serviceUrl,omitempty"`
	NodeOrgIds   []string `json:"nodeOrgids,omitempty"`
	SecondsStale int      `json:"secondsStale"`
	StartIndex   int      `json:"startIndex"`
	NumEntries   int      `json:"numEntries"`
}

Structs and types for working with pattern based exchange searches

func CreateSearchPatternRequest

func CreateSearchPatternRequest() *SearchExchangePatternRequest

This function creates the exchange search message body.

func (SearchExchangePatternRequest) String

type SearchExchangePatternResponse

type SearchExchangePatternResponse struct {
	Devices   []SearchResultDevice `json:"nodes"`
	LastIndex int                  `json:"lastIndex"`
}

func (SearchExchangePatternResponse) String

type SearchResultDevice

type SearchResultDevice struct {
	Id          string         `json:"id"`
	Name        string         `json:"name"`
	Services    []Microservice `json:"services"`
	MsgEndPoint string         `json:"msgEndPoint"`
	PublicKey   []byte         `json:"publicKey"`
}

func (SearchResultDevice) ShortString

func (d SearchResultDevice) ShortString() string

func (SearchResultDevice) String

func (d SearchResultDevice) String() string

type ServedPattern

type ServedPattern struct {
	NodeOrg     string `json:"nodeOrgid"`
	PatternOrg  string `json:"patternOrgid"`
	Pattern     string `json:"pattern"`
	LastUpdated string `json:"lastUpdated"`
}

type ServiceDefinition

type ServiceDefinition struct {
	Owner               string                `json:"owner"`
	Label               string                `json:"label"`
	Description         string                `json:"description"`
	Public              bool                  `json:"public"`
	URL                 string                `json:"url"`
	Version             string                `json:"version"`
	Arch                string                `json:"arch"`
	Sharable            string                `json:"sharable"`
	MatchHardware       HardwareRequirement   `json:"matchHardware"`
	RequiredServices    []ServiceDependency   `json:"requiredServices"`
	UserInputs          []UserInput           `json:"userInput"`
	Deployment          string                `json:"deployment"`
	DeploymentSignature string                `json:"deploymentSignature"`
	ImageStore          ImplementationPackage `json:"imageStore"`
	LastUpdated         string                `json:"lastUpdated"`
}

func GetHighestVersion

func GetHighestVersion(msMetadata map[string]ServiceDefinition, vRange *policy.Version_Expression) (string, ServiceDefinition, string, error)

Find the highest version service and return it.

func GetService

func GetService(ec ExchangeContext, mURL string, mOrg string, mVersion string, mArch string) (*ServiceDefinition, string, error)

Retrieve service definition metadata from the exchange, by specific version or for all versions.

func ServiceResolver

func ServiceResolver(wURL string, wOrg string, wVersion string, wArch string, serviceHandler ServiceHandler) (*policy.APISpecList, *ServiceDefinition, error)

The purpose of this function is to verify that a given service URL, version and architecture, is defined in the exchange as well as all of its required services. This function also returns the dependencies converted into policy types so that the caller can use those types to do policy compatibility checks if they want to.

func (*ServiceDefinition) GetDeployment

func (s *ServiceDefinition) GetDeployment() string

func (*ServiceDefinition) GetDeploymentSignature

func (s *ServiceDefinition) GetDeploymentSignature() string

func (*ServiceDefinition) GetImageStore

func (s *ServiceDefinition) GetImageStore() policy.ImplementationPackage

func (*ServiceDefinition) GetServiceDependencies

func (s *ServiceDefinition) GetServiceDependencies() *[]ServiceDependency

func (*ServiceDefinition) GetTorrent

func (s *ServiceDefinition) GetTorrent() string

func (*ServiceDefinition) GetUserInputName

func (s *ServiceDefinition) GetUserInputName(name string) *UserInput

func (*ServiceDefinition) GetVersion

func (s *ServiceDefinition) GetVersion() string

func (*ServiceDefinition) HasDependencies

func (s *ServiceDefinition) HasDependencies() bool

func (*ServiceDefinition) NeedsUserInput

func (s *ServiceDefinition) NeedsUserInput() bool

func (*ServiceDefinition) PopulateDefaultUserInput

func (s *ServiceDefinition) PopulateDefaultUserInput(envAdds map[string]string)

func (ServiceDefinition) ShortString

func (s ServiceDefinition) ShortString() string

func (ServiceDefinition) String

func (s ServiceDefinition) String() string

type ServiceDependency

type ServiceDependency struct {
	URL     string `json:"url"`
	Org     string `json:"org"`
	Version string `json:"version"`
	Arch    string `json:"arch"`
}

This type is a tuple used to refer to a specific service that is a dependency for the referencing service.

func (ServiceDependency) String

func (sd ServiceDependency) String() string

type ServiceDockerAuthsHandler

type ServiceDockerAuthsHandler func(sUrl string, sOrg string, sVersion string, sArch string) ([]ImageDockerAuth, error)

A handler for getting the image docker auths for a service in the exchange.

func GetHTTPServiceDockerAuthsHandler

func GetHTTPServiceDockerAuthsHandler(ec ExchangeContext) ServiceDockerAuthsHandler

type ServiceDockerAuthsWithIdHandler

type ServiceDockerAuthsWithIdHandler func(sId string) ([]ImageDockerAuth, error)

A handler for getting the image docker auths for a service by the id in the exchange.

func GetHTTPServiceDockerAuthsWithIdHandler

func GetHTTPServiceDockerAuthsWithIdHandler(ec ExchangeContext) ServiceDockerAuthsWithIdHandler

type ServiceHandler

type ServiceHandler func(wUrl string, wOrg string, wVersion string, wArch string) (*ServiceDefinition, string, error)

A handler for getting service metadata from the exchange.

func GetHTTPServiceHandler

func GetHTTPServiceHandler(ec ExchangeContext) ServiceHandler

type ServiceReference

type ServiceReference struct {
	ServiceURL      string           `json:"serviceUrl,omitempty"`      // refers to a service definition in the exchange
	ServiceOrg      string           `json:"serviceOrgid,omitempty"`    // the org holding the service definition
	ServiceArch     string           `json:"serviceArch,omitempty"`     // the hardware architecture of the service definition
	ServiceVersions []WorkloadChoice `json:"serviceVersions,omitempty"` // a list of service version for rollback
	DataVerify      DataVerification `json:"dataVerification"`          // policy for verifying that the node is sending data
	NodeH           NodeHealth       `json:"nodeHealth"`                // policy for determining when a node's health is violating its agreements
	AgreementLess   bool             `json:"agreementLess"`             // This service should get started on the node without an agreement to start it
}

func (ServiceReference) ShortString

func (w ServiceReference) ShortString() string

func (ServiceReference) String

func (w ServiceReference) String() string

type ServiceResolverHandler

type ServiceResolverHandler func(wUrl string, wOrg string, wVersion string, wArch string) (*policy.APISpecList, *ServiceDefinition, error)

A handler for resolving service references in the exchange.

func GetHTTPServiceResolverHandler

func GetHTTPServiceResolverHandler(ec ExchangeContext) ServiceResolverHandler

type SoftwareVersion

type SoftwareVersion map[string]string

type SymmetricValues

type SymmetricValues struct {
	Key   []byte `json:"key"`
	Nonce []byte `json:"nonce"`
}

type UpgradePolicy

type UpgradePolicy struct {
	Lifecycle string `json:"lifecycle,omitempty"` // immediate, never, agreement
	Time      string `json:"time,omitempty"`      // the time of the upgrade
}

type UserInput

type UserInput struct {
	Name         string `json:"name"`
	Label        string `json:"label"`
	Type         string `json:"type"` // Valid values are "string", "int", "float", "boolean", "list of strings"
	DefaultValue string `json:"defaultValue"`
}

This type is used to describe a configuration variable that the node owner/user has to set before the service is able to execute on the edge node.

func (UserInput) String

func (ui UserInput) String() string

type WorkloadAgreement

type WorkloadAgreement struct {
	Org     string `json:"orgid,omitempty"` // the org of the pattern
	Pattern string `json:"pattern"`         // pattern - without the org prefix on it
	URL     string `json:"url,omitempty"`   // workload URL
}

type WorkloadChoice

type WorkloadChoice struct {
	Version                      string           `json:"version,omitempty"`  // the version of the workload
	Priority                     WorkloadPriority `json:"priority,omitempty"` // the highest priority workload is tried first for an agreement, if it fails, the next priority is tried. Priority 1 is the highest, priority 2 is next, etc.
	Upgrade                      UpgradePolicy    `json:"upgradePolicy,omitempty"`
	DeploymentOverrides          string           `json:"deployment_overrides"`           // env var overrides for the workload
	DeploymentOverridesSignature string           `json:"deployment_overrides_signature"` // signature of env var overrides
}

func (WorkloadChoice) ShortString

func (w WorkloadChoice) ShortString() string

func (WorkloadChoice) String

func (w WorkloadChoice) String() string

type WorkloadPriority

type WorkloadPriority struct {
	PriorityValue     int `json:"priority_value,omitempty"`     // The priority of the workload
	Retries           int `json:"retries,omitempty"`            // The number of retries before giving up and moving to the next priority
	RetryDurationS    int `json:"retry_durations,omitempty"`    // The number of seconds in which the specified number of retries must occur in order for the next priority workload to be attempted.
	VerifiedDurationS int `json:"verified_durations,omitempty"` // The number of second in which verified data must exist before the rollback retry feature is turned off
}

type WrappedMessage

type WrappedMessage struct {
	Msg          []byte `json:"msg"`
	Signature    []byte `json:"signature"`
	SignerPubKey []byte `json:"signerPubkey"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址