persistence

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEVERITY_INFO  = "info"
	SEVERITY_WARN  = "warning"
	SEVERITY_ERROR = "error"
)

serverity for eventlog

View Source
const (
	SRC_TYPE_AG   = "agreement"
	SRC_TYPE_SVC  = "service"
	SRC_TYPE_NODE = "node"
	SRC_TYPE_DB   = "database"
	SRC_TYPE_EXCH = "exchange"
)

source type for eventlog

View Source
const (
	// general errors
	EC_DATABASE_ERROR       = "database_error"
	EC_API_USER_INPUT_ERROR = "api_user_input_error"
	EC_EXCHANGE_ERROR       = "exchange_error"

	// node configuration/registration
	EC_START_NODE_CONFIG_REG    = "start_node_configuration_registration"
	EC_NODE_CONFIG_REG_COMPLETE = "node_configuration_registration_complete"
	EC_ERROR_NODE_CONFIG_REG    = "error_node_configuration_registration"

	// node update
	EC_START_NODE_UPDATE    = "start_node_update"
	EC_NODE_UPDATE_COMPLETE = "node_update_complete"
	EC_ERROR_NODE_UPDATE    = "error_node_update"

	// node unreggistratin
	EC_START_NODE_UNREG    = "start_node_unregistration"
	EC_NODE_UNREG_COMPLETE = "node_unregistration_complete"
	EC_ERROR_NODE_UNREG    = "error_node_unregistration"

	// node heartbeat
	EC_NODE_HEARTBEAT_FAILED   = "node_heartbeat_failed"
	EC_NODE_HEARTBEAT_RESTORED = "node_heartbeat_restored"

	// service configuration
	EC_START_SERVICE_CONFIG    = "start_service_configuration"
	EC_SERVICE_CONFIG_COMPLETE = "service_configuration_complete"
	EC_ERROR_SERVICE_CONFIG    = "error_service_configuration"
	EC_WARNING_SERVICE_CONFIG  = "warning_service_configuration"

	// service config state
	EC_START_CHANGING_SERVICE_CONFIGSTATE    = "start_changing_service_configuration_state"
	EC_CHANGING_SERVICE_CONFIGSTATE_COMPLETE = "changing_service_configuration_state_complete"
	EC_ERROR_CHANGING_SERVICE_CONFIGSTATE    = "error_changing_service_configuration_state"

	// agreement related event code
	EC_RECEIVED_PROPOSAL         = "received_proposal"
	EC_IGNORE_PROPOSAL           = "ignore_proposal"
	EC_REJECT_PROPOSAL           = "reject_proposal"
	EC_ERROR_IN_PROPOSAL         = "error_in_proposal"
	EC_ERROR_PROCESSING_PROPOSAL = "error_processing_proposal"

	EC_RECEIVED_REPLYACK_MESSAGE         = "received_replyack_message"
	EC_IGNORE_REPLYACK_MESSAGE           = "ignore_replyack_message"
	EC_ERROR_PROCESSING_REPLYACT_MESSAGE = "error_ptocessing_replyack_message"

	EC_ERROR_PROCESSING_DATARECEIVED_MESSAGE = "error_processing_datareceived_message"

	EC_ERROR_PROCESSING_METERING_NOTIFY_MESSAGE = "error_processing_metering_notify_message"

	EC_RECEIVED_CANCEL_AGREEMENT_MESSAGE         = "received_cancel_agreement_message"
	EC_ERROR_PROCESSING_CANCEL_AGREEMENT_MESSAGE = "error_processing_cancel_agreement_message"

	EC_NODE_POLICY_UPDATED         = "update_node_policy"
	EC_NODE_POLICY_DELETED         = "delete_node_policy"
	EC_ERROR_NODE_POLICY_UPDATE    = "error_policy_update"
	EC_ERROR_NODE_POLICY_PATCH     = "error_policy_patch"
	EC_START_POLICY_ADVERTISING    = "start_policy_advertising"
	EC_COMPLETE_POLICY_ADVERTISING = "complete_policy_advertising"
	EC_ERROR_POLICY_ADVERTISING    = "error_policy_advertising"

	EC_NODE_USERINPUT_UPDATED      = "update_node_userinput"
	EC_NODE_USERINPUT_DELETED      = "delete_node_userinput"
	EC_ERROR_NODE_USERINPUT_UPDATE = "error_userinput_update"
	EC_ERROR_NODE_USERINPUT_PATCH  = "error_userinput_patch"

	EC_AGREEMENT_REACHED                  = "agreement_reached"
	EC_CANCEL_AGREEMENT                   = "cancel_agreement"
	EC_AGREEMENT_CANCELED                 = "agreement_canceled"
	EC_CANCEL_AGREEMENT_EXECUTION_TIMEOUT = "cancel_agreement_execution_timeout"
	EC_CANCEL_AGREEMENT_NO_REPLYACK       = "cancel_agreement_no_replyack"
	EC_CANCEL_AGREEMENT_PER_AGBOT         = "cancel_agreement_per_agbot_request"
	EC_CANCEL_AGREEMENT_SERVICE_SUSPENDED = "cancel_agreement_service_suspended"
	EC_CANCEL_AGREEMENT_POLICY_CHANGED    = "cancel_agreement_policy_changed"

	EC_CONTAINER_RUNNING          = "container_running"
	EC_CONTAINER_STOPPED          = "container_stopped"
	EC_ERROR_IN_DEPLOYMENT_CONFIG = "error_in_deployment_configuration"
	EC_ERROR_START_CONTAINER      = "error_start_container"

	EC_IMAGE_LOADED                       = "image_loaded"
	EC_ERROR_IMAGE_LOADE                  = "error_image_load"
	EC_ERROR_AGREEMENT_VERIFICATION       = "error_in_agreement_verification"
	EC_ERROR_DELETE_AGREEMENT_IN_EXCHANGE = "error_delete_agreement_in_exchange"

	// event code for services
	EC_START_SERVICE            = "start_service"
	EC_ERROR_START_SERVICE      = "error_start_service"
	EC_COMPLETE_SERVICE_STARTUP = "complete_service_startup"

	EC_START_DEPENDENT_SERVICE             = "start_dependent_service"
	EC_ERROR_START_DEPENDENT_SERVICE       = "error_start_dependent_service"
	EC_DEPENDENT_SERVICE_FAILED            = "dependent_service_failed"
	EC_COMPLETE_DEPENDENT_SERVICE          = "complete_dependent_service"
	EC_REMOVE_OLD_DEPENDENT_SERVICE_FAILED = "remove_old_dependent_service_failed"

	EC_START_RETRY_DEPENDENT_SERVICE       = "start_retry_dependent_service"
	EC_ERROR_START_RETRY_DEPENDENT_SERVICE = "error_start_retry_dependent_service"
	EC_DEPENDENT_SERVICE_RETRY_FAILED      = "dependent_service_retry_failed"
	EC_COMPLETE_RETRY_DEPENDENT_SERVICE    = "complete_retry_dependent_service"

	EC_START_AGREEMENTLESS_SERVICE            = "start_agreementless_service"
	EC_ERROR_START_AGREEMENTLESS_SERVICE      = "error_start_agreementless_service"
	EC_COMPLETE_AGREEMENTLESS_SERVICE_STARTUP = "complete_agreementless_service_startup"

	EC_START_DOWNGRADE_SERVICE    = "start_downgrade_service"
	EC_COMPLETE_DOWNGRADE_SERVICE = "complete_downgrade_service"
	EC_ERROR_DOWNGRADE_SERVICE    = "error_downgrade_service"
	EC_NO_VERSION_TO_DOWNGRADE    = "no_version_to_downgrade"

	EC_START_UPGRADE_SERVICE    = "start_rollback_service"
	EC_COMPLETE_UPGRADE_SERVICE = "complete_rollback_service"
	EC_ERROR_UPGRADE_SERVICE    = "error_rollback_service"

	EC_START_CLEANUP_SERVICE    = "start_cleanup_service"
	EC_COMPLETE_CLEANUP_SERVICE = "complete_cleanup_service"
	EC_ERROR_CLEANUP_SERVICE    = "error_cleanup_service"
)

event code for eventlog

View Source
const ATTRIBUTES = "attributes"

a "service is a v2.1.0 transitional concept: it stores patterned service-related information from v1 PoCs

View Source
const BASE_SELECTORS = "source_type,severity,message,event_code,record_id,timestamp" // only support these 2 for now
View Source
const CONFIGSTATE_CONFIGURED = "configured"
View Source
const CONFIGSTATE_CONFIGURING = "configuring"
View Source
const CONFIGSTATE_UNCONFIGURED = "unconfigured"
View Source
const CONFIGSTATE_UNCONFIGURING = "unconfiguring"
View Source
const DEVICES = "devices"
View Source
const DEVMODE = "devmode"
View Source
const EVENT_LOGS = "event_logs"

event log table name

View Source
const EXCHANGE_NODE_USERINPUT_HASH = "exchange_node_userinput_hash" // The buucket for the exchange node userinput hash
View Source
const EXCHANGE_NP_LAST_UPDATED = "exchange_nodepolicy_lastupdated" // The buucket for the exchange last updated string
View Source
const E_AGREEMENTS = "established_agreements" // may or may not be in agreements

ephemeral as of v2.1.0

View Source
const LAST_UNREG = "last_unreg"

table stores the timestamp of last unregistration

View Source
const MICROSERVICE_DEFINITIONS = "microdevice_definitions"
View Source
const MICROSERVICE_INSTANCES = "microdevice_instances"

microdevice definition table name

View Source
const NODE_POLICY = "nodepolicy" // The bucket name in the bolt DB.

Constants used throughout the code.

View Source
const NODE_SURFACEERR = "nodesurfaceerror"
View Source
const NODE_USERINPUT = "nodeuserinput" // The bucket name in the bolt DB.

Variables

View Source
var RemoveDatabaseOnExit bool

Functions

func AttributesToEnvvarMap

func AttributesToEnvvarMap(attributes []Attribute, envvars map[string]string, prefix string, defaultRAM int64) (map[string]string, error)

This function is used to convert the persistent attributes for a service to an env var map. This will include *all* values for which HostOnly is false, include those marked to not publish.

func CompareServiceInstancePath

func CompareServiceInstancePath(a, b []ServiceInstancePathElement) bool

func ConvertToSelectors

func ConvertToSelectors(selections map[string][]string) (map[string][]Selector, error)

convert the given http.Request.Form into map of Selectors

func DeleteAllUserInputAttributes

func DeleteAllUserInputAttributes(db *bolt.DB) error

Delete all UserInputAttributes from the local db.

func DeleteAsscAgmtsFromMSInstances

func DeleteAsscAgmtsFromMSInstances(db *bolt.DB, agreement_id string) error

delete associated agreement id from all the microservice instances

func DeleteEstablishedAgreement

func DeleteEstablishedAgreement(db *bolt.DB, agreementId string, protocol string) error

func DeleteExchangeDevice

func DeleteExchangeDevice(db *bolt.DB) error

func DeleteNodePolicy

func DeleteNodePolicy(db *bolt.DB) error

Remove the node policy object from the local database.

func DeleteNodePolicyLastUpdated_Exch

func DeleteNodePolicyLastUpdated_Exch(db *bolt.DB) error

Remove the exchange node policy lastUpdated string from the local database.

func DeleteNodeUserInput

func DeleteNodeUserInput(db *bolt.DB) error

Remove the node user input object from the local database.

func DeleteNodeUserInputHash_Exch

func DeleteNodeUserInputHash_Exch(db *bolt.DB) error

Remove the exchange node user input hash from the local database.

func FindNodePolicy

func FindNodePolicy(db *bolt.DB) (*externalpolicy.ExternalPolicy, error)

Retrieve the node policy object from the database. The bolt APIs assume there is more than 1 object in a bucket, so this function has to be prepared for that case, even though there should only ever be 1.

func FindNodeUserInput

func FindNodeUserInput(db *bolt.DB) ([]policy.UserInput, error)

Retrieve the node user input object from the database. The bolt APIs assume there is more than 1 object in a bucket, so this function has to be prepared for that case, even though there should only ever be 1.

func GetFormatedPatternString

func GetFormatedPatternString(pattern string, device_org string) (string, string, string)

This function returns the pattern org, pattern name and formatted pattern string 'pattern org/pattern name'. If the input pattern does not contain the org name, the device org name will be used as the pattern org name. The input is a pattern string 'pattern org/pattern name' or just 'pattern name' for backward compatibility. The device org is the org name for the device.

func GetLastUnregistrationTime

func GetLastUnregistrationTime(db *bolt.DB) (uint64, error)

Find the event log from the db

func GetNodePolicyLastUpdated_Exch

func GetNodePolicyLastUpdated_Exch(db *bolt.DB) (string, error)

Retrieve the exchange node policy lastUpdated string from the database.

func GetNodeUserInputHash_Exch

func GetNodeUserInputHash_Exch(db *bolt.DB) ([]byte, error)

Retrieve the exchange node user input hash from the database.

func GetRemoveDatabaseOnExit

func GetRemoveDatabaseOnExit() bool

func GroupSelectors

func GroupSelectors(selectors map[string][]Selector) (map[string][]Selector, map[string][]Selector)

This function separates base selectors and source selectors. It returns (base_selectors, source_selectors)

func IsHelm

func IsHelm(dep map[string]interface{}) bool

func IsSurfaceType

func IsSurfaceType(errorType string) bool

IsSurfaceType returns true if the string parameter is a type to surface to the exchange

func MatchAttributeValue

func MatchAttributeValue(attr interface{}, selectors []Selector) (bool, bool, error)

Given the selector, check if the given attribute match or not. Example:

MatchTypes("this is a test", [{ "~", "test"}, {"~", "aaa"}])
  --- check the string to see if it contains "test" and "aaa".
MatchTypes(12345, [{">", 100}])
  --- check the integer to see if it is greater than 100.

This function returns (match_or_not, handled_or_not, error)

func MatchWorkload

func MatchWorkload(error1 EventLog, error2 EventLog) bool

MatchWorkload function checks if the 2 eventlog parameters have matching workloads

func MigrateExchangeDevice

func MigrateExchangeDevice(db *bolt.DB) (bool, error)

Migrate a device object if it is restarted ona newer level of code.

func NewErrorLog

func NewErrorLog(db *bolt.DB, eventLog EventLog) bool

NewErrorLog takes an eventLog object and puts it in the local db and exchange if it should be surfaced

func SaveEventLog

func SaveEventLog(db *bolt.DB, event_log *EventLog) error

save the event log record into db.

func SaveLastUnregistrationTime

func SaveLastUnregistrationTime(db *bolt.DB, last_unreg_time uint64) error

save the timestamp for the last unregistration into db.

func SaveNodePolicy

func SaveNodePolicy(db *bolt.DB, nodePolicy *externalpolicy.ExternalPolicy) error

There is only 1 object in the bucket so we can use the bucket name as the object key.

func SaveNodePolicyLastUpdated_Exch

func SaveNodePolicyLastUpdated_Exch(db *bolt.DB, lastUpdated string) error

save the exchange node policy lastUpdated string.

func SaveNodeUserInput

func SaveNodeUserInput(db *bolt.DB, userInput []policy.UserInput) error

There is only 1 object in the bucket so we can use the bucket name as the object key.

func SaveNodeUserInputHash_Exch

func SaveNodeUserInputHash_Exch(db *bolt.DB, userInputHash []byte) error

save the exchange node user input hash.

func SaveOrUpdateMicroserviceDef

func SaveOrUpdateMicroserviceDef(db *bolt.DB, msdef *MicroserviceDefinition) error

save the microservice record. update if it already exists in the db

func SaveSurfaceErrors

func SaveSurfaceErrors(db *bolt.DB, surfaceErrors []SurfaceError) error

SaveSurfaceErrors saves the provided list of surface errors to the local db

func ServiceConfigNames

func ServiceConfigNames(serviceConfigs *map[string]ServiceConfig) []string

func SetRemoveDatabaseOnExit

func SetRemoveDatabaseOnExit(remove bool)

Types

type AgreementEventSource

type AgreementEventSource struct {
	AgreementId       string       `json:"agreement_id"`
	RunningWorkload   WorkloadInfo `json:"workload_to_run"`
	DependentServices ServiceSpecs `json:"dependent_services"`
	ConsumerId        string       `json:"consumer_id"`
	AgreementProtocol string       `json:"agreement_protocol"`
}

func NewAgreementEventSource

func NewAgreementEventSource(agreement_id string, workload WorkloadInfo, dependent_svcs ServiceSpecs, consumer_id string, protocol string) *AgreementEventSource

func NewAgreementEventSourceFromAg

func NewAgreementEventSourceFromAg(ag EstablishedAgreement) *AgreementEventSource

func (AgreementEventSource) Matches

func (w AgreementEventSource) Matches(selectors map[string][]Selector) bool

func (AgreementEventSource) ShortString

func (w AgreementEventSource) ShortString() string

func (AgreementEventSource) String

func (w AgreementEventSource) String() string

type AgreementProtocolAttributes

type AgreementProtocolAttributes struct {
	Meta         *AttributeMeta `json:"meta"`
	ServiceSpecs *ServiceSpecs  `json:"service_specs"`
	Protocols    interface{}    `json:"protocols"`
}

func (AgreementProtocolAttributes) GetGenericMappings

func (a AgreementProtocolAttributes) GetGenericMappings() map[string]interface{}

func (AgreementProtocolAttributes) GetMeta

func (AgreementProtocolAttributes) GetServiceSpecs

func (a AgreementProtocolAttributes) GetServiceSpecs() *ServiceSpecs

func (AgreementProtocolAttributes) String

func (AgreementProtocolAttributes) Update

TODO: duplicate this for the others too

type Attribute

type Attribute interface {
	GetMeta() *AttributeMeta
	GetGenericMappings() map[string]interface{}
	Update(other Attribute) error
	String() string
}

func DeleteAttribute

func DeleteAttribute(db *bolt.DB, id string) (*Attribute, error)

func FindApplicableAttributes

func FindApplicableAttributes(db *bolt.DB, serviceUrl string, org string) ([]Attribute, error)

get all the attribute that the given this service can use. If the given serviceUrl is an empty string, all attributes will be returned. For an attribute, if the a.ServiceSpecs is empty, it will be included. Otherwise, if an element in the attrubute's ServiceSpecs array equals to ServiceSpec{serviceUrl, org} the attribute will be included.

func FindAttributeByKey

func FindAttributeByKey(db *bolt.DB, id string) (*Attribute, error)

FindAttributeByKey is used to fetch a single attribute by its primary key

func FindConflictingAttributes

func FindConflictingAttributes(db *bolt.DB, attribute *Attribute) (*Attribute, error)

func HydrateConcreteAttribute

func HydrateConcreteAttribute(v []byte) (Attribute, error)

func SaveOrUpdateAttribute

func SaveOrUpdateAttribute(db *bolt.DB, attr Attribute, id string, permitPartialOverwrite bool) (*Attribute, error)

N.B. It's the caller's responsibility to ensure the attr.ServiceSpecs are deduplicated; use the ServiceSpecs.AddServiceSpec() function to keep the slice clean

type AttributeMeta

type AttributeMeta struct {
	Id          string `json:"id"` // should correspond to something meangingful to the caller
	Type        string `json:"type"`
	Label       string `json:"label"`       // for humans only, never computable
	HostOnly    *bool  `json:"host_only"`   // determines whether or not the attribute will be published inside workload containers or exists only for Host use
	Publishable *bool  `json:"publishable"` // means sent to exchange or otherwise published; whether or not an attr ends up in a workload depends on the value of HostOnly
}

func (AttributeMeta) String

func (a AttributeMeta) String() string

func (*AttributeMeta) Update

func (m *AttributeMeta) Update(meta AttributeMeta)

Update *selectively* updates the content of this AttributeMeta (m) with non-empty values in the given meta.

type Auth

type Auth struct {
	Registry string `json:"registry"`
	UserName string `json:"username"` // The name of the user, the default is 'token'
	Token    string `json:"token"`    // It can be a token, a password, an api key etc.
}

type Configstate

type Configstate struct {
	State          string `json:"state"`
	LastUpdateTime uint64 `json:"last_update_time"`
}

func (Configstate) String

func (c Configstate) String() string

type ConflictingAttributeFound

type ConflictingAttributeFound struct {
	// contains filtered or unexported fields
}

func (ConflictingAttributeFound) Error

type DatabaseEventSource

type DatabaseEventSource struct {
}

func NewDatabaseEventSource

func NewDatabaseEventSource() *DatabaseEventSource

func (DatabaseEventSource) Matches

func (w DatabaseEventSource) Matches(selectors map[string][]Selector) bool

func (DatabaseEventSource) ShortString

func (w DatabaseEventSource) ShortString() string

func (DatabaseEventSource) String

func (w DatabaseEventSource) String() string

type DeploymentConfig

type DeploymentConfig interface {
	ToPersistentForm() (map[string]interface{}, error)
	FromPersistentForm(pf map[string]interface{}) error
	IsNative() bool
	ToString() string
}

type DockerRegistryAuthAttributes

type DockerRegistryAuthAttributes struct {
	Meta  *AttributeMeta `json:"meta"`
	Auths []Auth         `json:"auths"`
}

func (DockerRegistryAuthAttributes) AddAuth

func (a DockerRegistryAuthAttributes) AddAuth(auth_new Auth)

add a new auth token to this registery

func (DockerRegistryAuthAttributes) DeleteAuth

func (a DockerRegistryAuthAttributes) DeleteAuth(auth_in Auth)

delete the given auth from this registery

func (DockerRegistryAuthAttributes) GetGenericMappings

func (a DockerRegistryAuthAttributes) GetGenericMappings() map[string]interface{}

func (DockerRegistryAuthAttributes) GetMeta

func (DockerRegistryAuthAttributes) String

func (DockerRegistryAuthAttributes) Update

type EAFilter

type EAFilter func(EstablishedAgreement) bool

filter on EstablishedAgreements

func IdEAFilter

func IdEAFilter(id string) EAFilter

func UnarchivedEAFilter

func UnarchivedEAFilter() EAFilter

type EstablishedAgreement

type EstablishedAgreement struct {
	Name                         string       `json:"name"`
	DependentServices            ServiceSpecs `json:"dependent_services"`
	Archived                     bool         `json:"archived"`
	CurrentAgreementId           string       `json:"current_agreement_id"`
	ConsumerId                   string       `json:"consumer_id"`
	CounterPartyAddress          string       `json:"counterparty_address"`
	AgreementCreationTime        uint64       `json:"agreement_creation_time"`
	AgreementAcceptedTime        uint64       `json:"agreement_accepted_time"`
	AgreementBCUpdateAckTime     uint64       `json:"agreement_bc_update_ack_time"` // V2 protocol - time when consumer acks our blockchain update
	AgreementFinalizedTime       uint64       `json:"agreement_finalized_time"`
	AgreementTerminatedTime      uint64       `json:"agreement_terminated_time"`
	AgreementForceTerminatedTime uint64       `json:"agreement_force_terminated_time"`
	AgreementExecutionStartTime  uint64       `json:"agreement_execution_start_time"`
	AgreementDataReceivedTime    uint64       `json:"agreement_data_received_time"`
	// One of the following 2 fields are set when the worker that owns deployment for this agreement, starts deploying the services in the agreement.
	CurrentDeployment               map[string]ServiceConfig `json:"current_deployment"`  // Native Horizon deployment config goes here, mutually exclusive with the extended deployment field. This field is set before the imagefetch worker starts the workload.
	ExtendedDeployment              map[string]interface{}   `json:"extended_deployment"` // All non-native deployment configs go here. This field is set before the helm worker installs the release.
	Proposal                        string                   `json:"proposal"`
	ProposalSig                     string                   `json:"proposal_sig"`           // the proposal currently in effect
	AgreementProtocol               string                   `json:"agreement_protocol"`     // the agreement protocol being used. It is also in the proposal.
	ProtocolVersion                 int                      `json:"protocol_version"`       // the agreement protocol version being used.
	TerminatedReason                uint64                   `json:"terminated_reason"`      // the reason that the agreement was terminated
	TerminatedDescription           string                   `json:"terminated_description"` // a string form of the reason that the agreement was terminated
	AgreementProtocolTerminatedTime uint64                   `json:"agreement_protocol_terminated_time"`
	WorkloadTerminatedTime          uint64                   `json:"workload_terminated_time"`
	MeteringNotificationMsg         MeteringNotification     `json:"metering_notification,omitempty"` // the most recent metering notification received
	BlockchainType                  string                   `json:"blockchain_type,omitempty"`       // the name of the type of the blockchain
	BlockchainName                  string                   `json:"blockchain_name,omitempty"`       // the name of the blockchain instance
	BlockchainOrg                   string                   `json:"blockchain_org,omitempty"`        // the org of the blockchain instance
	RunningWorkload                 WorkloadInfo             `json:"workload_to_run,omitempty"`       // For display purposes, a copy of the workload info that this agreement is managing. It should be the same info that is buried inside the proposal.
}

N.B. Important!! Ensure new values are handled in Update function below This struct is for persisting agreements

func AgreementDeploymentStarted

func AgreementDeploymentStarted(db *bolt.DB, dbAgreementId string, protocol string, deployment DeploymentConfig) (*EstablishedAgreement, error)

set deployment config because execution is about to begin

func AgreementStateAccepted

func AgreementStateAccepted(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to accepted, a positive reply is being sent

func AgreementStateAgreementProtocolTerminated

func AgreementStateAgreementProtocolTerminated(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to agreement protocol terminated

func AgreementStateBCDataReceived

func AgreementStateBCDataReceived(db *bolt.DB, dbAgreementId string, protocol string, address string) (*EstablishedAgreement, error)

set the eth counterparty address when it is received from the consumer

func AgreementStateBCUpdateAcked

func AgreementStateBCUpdateAcked(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set the time when out agreement blockchain update message was Ack'd.

func AgreementStateDataReceived

func AgreementStateDataReceived(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to data received

func AgreementStateExecutionStarted

func AgreementStateExecutionStarted(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to execution started

func AgreementStateFinalized

func AgreementStateFinalized(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to finalized

func AgreementStateForceTerminated

func AgreementStateForceTerminated(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

reset agreement state to not-terminated so that we can retry the termination

func AgreementStateProposalSigned

func AgreementStateProposalSigned(db *bolt.DB, dbAgreementId string, protocol string, sig string) (*EstablishedAgreement, error)

set the eth signature of the proposal

func AgreementStateTerminated

func AgreementStateTerminated(db *bolt.DB, dbAgreementId string, reason uint64, reasonString string, protocol string) (*EstablishedAgreement, error)

set agreement state to terminated

func AgreementStateWorkloadTerminated

func AgreementStateWorkloadTerminated(db *bolt.DB, dbAgreementId string, protocol string) (*EstablishedAgreement, error)

set agreement state to workload terminated

func ArchiveEstablishedAgreement

func ArchiveEstablishedAgreement(db *bolt.DB, agreementId string, protocol string) (*EstablishedAgreement, error)

func FindEstablishedAgreements

func FindEstablishedAgreements(db *bolt.DB, protocol string, filters []EAFilter) ([]EstablishedAgreement, error)

func FindEstablishedAgreementsAllProtocols

func FindEstablishedAgreementsAllProtocols(db *bolt.DB, protocols []string, filters []EAFilter) ([]EstablishedAgreement, error)

func MeteringNotificationReceived

func MeteringNotificationReceived(db *bolt.DB, dbAgreementId string, mn MeteringNotification, protocol string) (*EstablishedAgreement, error)

set agreement state to workload terminated

func NewEstablishedAgreement

func NewEstablishedAgreement(db *bolt.DB, name string, agreementId string, consumerId string, proposal string, protocol string, protocolVersion int, dependentSvcs ServiceSpecs, signature string, address string, bcType string, bcName string, bcOrg string, wi *WorkloadInfo) (*EstablishedAgreement, error)

func (*EstablishedAgreement) GetDeploymentConfig

func (a *EstablishedAgreement) GetDeploymentConfig() DeploymentConfig

Return either the CurrentDeployment or the ExtendedDeployment, depending on which is set, in a form that implements the DeploymentConfig interface.

func (EstablishedAgreement) String

func (c EstablishedAgreement) String() string

type EventLog

type EventLog struct {
	EventLogBase
	Source EventSourceInterface `json:"event_source"` // source involved for this event.
}

func FindAllEventLogs

func FindAllEventLogs(db *bolt.DB) ([]EventLog, error)

find all event logs from the db

func FindEventLogWithKey

func FindEventLogWithKey(db *bolt.DB, key string) (*EventLog, error)

Find the event log from the db

func FindEventLogs

func FindEventLogs(db *bolt.DB, filters []EventLogFilter) ([]EventLog, error)

find event logs from the db for the given filters

func FindEventLogsWithSelectors

func FindEventLogsWithSelectors(db *bolt.DB, all_logs bool, selectors map[string][]Selector, msgPrinter *message.Printer) ([]EventLog, error)

find event logs from the db for the given given selectors. If all_logs is false, only the event logs for the current registration is returned.

func GetEventLogObject

func GetEventLogObject(db *bolt.DB, msgPrinter *message.Printer, recordID string) EventLog

GetEventLogObject returns the full eventlog object associated with a given record id

func NewEventLog

func NewEventLog(severity string, message_meta *MessageMeta, event_code string, source_type string, source EventSourceInterface) *EventLog

func (EventLog) IsSourceType

func (w EventLog) IsSourceType(source_type string) bool

Checks the source type of the event log. An eventlog can belong to different source types at the same time.

func (EventLog) Matches

func (w EventLog) Matches(selectors map[string][]Selector) bool

Checks if the event log matches the selectors For example:

  selectors = [string][]Selector{
			"a": [{"~": "test"}, {"~", "agreement"}],
         "b": [{"=", "this is a test"}],
			"c":[{">", 100}]
		}

It means checking if this event log matches the following logic:

the attribute "a" contains the word "test" and "agreement",
and attribute "b" equals "this is a test" and attribute "c" is greater than 100.

func (EventLog) Matches2

func (w EventLog) Matches2(base_selectors map[string][]Selector, source_selectors map[string][]Selector) bool

Checks if the event log matches the base selectors and source selectors

func (EventLog) ShortString

func (w EventLog) ShortString() string

func (EventLog) String

func (w EventLog) String() string

type EventLogBase

type EventLogBase struct {
	Id          string       `json:"record_id"` // unique primary key for records
	Timestamp   uint64       `json:"timestamp"`
	Severity    string       `json:"severity"` // info, warning or error
	Message     string       `json:"message"`  // obsolte in DB, used for backward compatibility and for output
	EventCode   string       `json:"event_code"`
	SourceType  string       `json:"source_type"`            // the type of the source. It can be agreement, service, image, workload etc.
	MessageMeta *MessageMeta `json:"message_meta,omitempty"` // the message and it's arguements for fmt.Sprintf. This is used for i18n.
}

func (EventLogBase) Matches

func (w EventLogBase) Matches(selectors map[string][]Selector) bool

Checks if the base event log matches the selectors

type EventLogFilter

type EventLogFilter func(EventLog) bool

filter on MicroserviceDefinition

func SelectorFilter

func SelectorFilter(selectors map[string][]Selector) EventLogFilter

filter on the source type and value

func SeverityELFilter

func SeverityELFilter(severity string) EventLogFilter

filter on severity

func SourceTypeELFilter

func SourceTypeELFilter(source_type string) EventLogFilter

filter on source type

type EventLogRaw

type EventLogRaw struct {
	EventLogBase
	Source *json.RawMessage `json:"event_source"` // source involved for this event.
}

type EventSourceInterface

type EventSourceInterface interface {

	//Used for searching. The input is a map of selector array.
	// The input is a map of selector array.
	// For example:
	//   selectors = [string][]Selector{
	//			"a": [{"~": "test"}, {"~", "agreement"}],
	//          "b": [{"=", "this is a test"}],
	//			"c":[{">", 100}]
	//		}
	// It means checking if this event source matches the following logic:
	//  the attribute "a" contains the word "test" and "agreement",
	//  attribute "b" equals "this is a test" and attribute "c" is greater than 100.
	Matches(map[string][]Selector) bool
}

Each event source implements this interface.

type ExchangeDevice

type ExchangeDevice struct {
	Id                 string      `json:"id"`
	Org                string      `json:"organization"`
	Pattern            string      `json:"pattern"`
	Name               string      `json:"name"`
	Token              string      `json:"token"`
	TokenLastValidTime uint64      `json:"token_last_valid_time"`
	TokenValid         bool        `json:"token_valid"`
	HA                 bool        `json:"ha"`
	Config             Configstate `json:"configstate"`
}

func FindExchangeDevice

func FindExchangeDevice(db *bolt.DB) (*ExchangeDevice, error)

func SaveNewExchangeDevice

func SaveNewExchangeDevice(db *bolt.DB, id string, token string, name string, ha bool, organization string, pattern string, configstate string) (*ExchangeDevice, error)

always assumed the given token is valid at the time of call

func (ExchangeDevice) GetId

func (e ExchangeDevice) GetId() string

func (*ExchangeDevice) InvalidateExchangeToken

func (e *ExchangeDevice) InvalidateExchangeToken(db *bolt.DB) (*ExchangeDevice, error)

a convenience function b/c we know there is really only one device

func (*ExchangeDevice) IsState

func (e *ExchangeDevice) IsState(state string) bool

func (*ExchangeDevice) SetConfigstate

func (e *ExchangeDevice) SetConfigstate(db *bolt.DB, deviceId string, state string) (*ExchangeDevice, error)

func (*ExchangeDevice) SetExchangeDeviceToken

func (e *ExchangeDevice) SetExchangeDeviceToken(db *bolt.DB, deviceId string, token string) (*ExchangeDevice, error)

func (ExchangeDevice) String

func (e ExchangeDevice) String() string

type ExchangeEventSource

type ExchangeEventSource struct {
	ExchangeUrl string `json:"exchange_url"`
}

func NewExchangeEventSource

func NewExchangeEventSource(exchange_url string) *ExchangeEventSource

func (ExchangeEventSource) Matches

func (w ExchangeEventSource) Matches(selectors map[string][]Selector) bool

func (ExchangeEventSource) ShortString

func (w ExchangeEventSource) ShortString() string

func (ExchangeEventSource) String

func (w ExchangeEventSource) String() string

type HAAttributes

type HAAttributes struct {
	Meta     *AttributeMeta `json:"meta"`
	Partners []string       `json:"partners"`
}

func (HAAttributes) GetGenericMappings

func (a HAAttributes) GetGenericMappings() map[string]interface{}

func (HAAttributes) GetMeta

func (a HAAttributes) GetMeta() *AttributeMeta

func (HAAttributes) PartnersContains

func (a HAAttributes) PartnersContains(id string) bool

func (HAAttributes) String

func (a HAAttributes) String() string

func (HAAttributes) Update

func (a HAAttributes) Update(other Attribute) error

TODO: duplicate this for the others too

type HTTPSBasicAuthAttributes

type HTTPSBasicAuthAttributes struct {
	Meta     *AttributeMeta `json:"meta"`
	Url      string         `json:"url"`
	Username string         `json:"username"`
	Password string         `json:"password"`
}

func (HTTPSBasicAuthAttributes) GetGenericMappings

func (a HTTPSBasicAuthAttributes) GetGenericMappings() map[string]interface{}

func (HTTPSBasicAuthAttributes) GetMeta

func (HTTPSBasicAuthAttributes) String

func (a HTTPSBasicAuthAttributes) String() string

func (HTTPSBasicAuthAttributes) Update

func (a HTTPSBasicAuthAttributes) Update(other Attribute) error

type HardwareMatch

type HardwareMatch map[string]interface{}

type HelmDeploymentConfig

type HelmDeploymentConfig struct {
	ChartArchive string `json:"chart_archive"` // base64 encoded binary of helm package tar file
	ReleaseName  string `json:"release_name"`
}

func GetHelmDeployment

func GetHelmDeployment(depStr string) (*HelmDeploymentConfig, error)

Given a deployment string, unmarshal it as a HelmDeployment object. It might not be a HelmDeployment, so we have to verify what was just unmarshalled.

func NewHelmDeployment

func NewHelmDeployment(chartArchive string, releaseName string) *HelmDeploymentConfig

func (*HelmDeploymentConfig) FromPersistentForm

func (h *HelmDeploymentConfig) FromPersistentForm(pf map[string]interface{}) error

func (*HelmDeploymentConfig) IsNative

func (h *HelmDeploymentConfig) IsNative() bool

func (HelmDeploymentConfig) String

func (h HelmDeploymentConfig) String() string

func (*HelmDeploymentConfig) ToPersistentForm

func (h *HelmDeploymentConfig) ToPersistentForm() (map[string]interface{}, error)

func (*HelmDeploymentConfig) ToString

func (h *HelmDeploymentConfig) ToString() string

type MIFilter

type MIFilter func(MicroserviceInstance) bool

filter on MicroserviceInstance

func AllInstancesMIFilter

func AllInstancesMIFilter(spec_url string, org string, version string) MIFilter

filter for all the microservice instances for the given url and org and version

func AllMIFilter

func AllMIFilter() MIFilter

filter for all microservice instances

func NotCleanedUpMIFilter

func NotCleanedUpMIFilter() MIFilter

func UnarchivedMIFilter

func UnarchivedMIFilter() MIFilter

type MSFilter

type MSFilter func(MicroserviceDefinition) bool

filter on MicroserviceDefinition

func AllMSFilter

func AllMSFilter() MSFilter

filter for all microservice defs

func ArchivedMSFilter

func ArchivedMSFilter() MSFilter

filter for all archived msdefs

func UnarchivedMSFilter

func UnarchivedMSFilter() MSFilter

filter for all unarchived msdefs

func UrlMSFilter

func UrlMSFilter(spec_url string) MSFilter

filter for all the microservice defs for the given url

func UrlOrgMSFilter

func UrlOrgMSFilter(spec_url string, org string) MSFilter

filter on the url + + org

func UrlOrgVersionMSFilter

func UrlOrgVersionMSFilter(spec_url string, org string, version string) MSFilter

filter on the url + version + org

type MessageMeta

type MessageMeta struct {
	MessageKey  string        `json:"message_key"`
	MessageArgs []interface{} `json:"message_args,omitempty"`
}

This structure is used to store the message key and args for fmt.Sprintf(). It can be used by the MessagePrinter.Sprintf to print out the messages for different locales.

func NewMessageMeta

func NewMessageMeta(msg_key string, message_args ...interface{}) *MessageMeta

func (MessageMeta) String

func (w MessageMeta) String() string

type MetaAttributesOnly

type MetaAttributesOnly struct {
	Meta *AttributeMeta `json:"meta"`
}

func (MetaAttributesOnly) GetGenericMappings

func (a MetaAttributesOnly) GetGenericMappings() map[string]interface{}

func (MetaAttributesOnly) GetMeta

func (a MetaAttributesOnly) GetMeta() *AttributeMeta

type MeteringAttributes

type MeteringAttributes struct {
	Meta                  *AttributeMeta `json:"meta"`
	ServiceSpecs          *ServiceSpecs  `json:"service_specs"`
	Tokens                uint64         `json:"tokens"`
	PerTimeUnit           string         `json:"per_time_unit"`
	NotificationIntervalS int            `json:"notification_interval"`
}

func (MeteringAttributes) GetGenericMappings

func (a MeteringAttributes) GetGenericMappings() map[string]interface{}

func (MeteringAttributes) GetMeta

func (a MeteringAttributes) GetMeta() *AttributeMeta

func (MeteringAttributes) GetServiceSpecs

func (a MeteringAttributes) GetServiceSpecs() *ServiceSpecs

func (MeteringAttributes) String

func (a MeteringAttributes) String() string

func (MeteringAttributes) Update

func (a MeteringAttributes) Update(other Attribute) error

TODO: duplicate this for the others too

type MeteringNotification

type MeteringNotification struct {
	Amount                 uint64 `json:"amount"`                       // The number of tokens granted by this notification, rounded to the nearest minute
	StartTime              uint64 `json:"start_time"`                   // The time when the agreement started, in seconds since 1970.
	CurrentTime            uint64 `json:"current_time"`                 // The time when the notification was sent, in seconds since 1970.
	MissedTime             uint64 `json:"missed_time"`                  // The amount of time in seconds that the consumer detected missing data
	ConsumerMeterSignature string `json:"consumer_meter_signature"`     // The consumer's signature of the meter (amount, current time, agreement Id)
	AgreementHash          string `json:"agreement_hash"`               // The 32 byte SHA3 FIPS 202 hash of the proposal for the agreement.
	ConsumerSignature      string `json:"consumer_agreement_signature"` // The consumer's signature of the agreement hash.
	ConsumerAddress        string `json:"consumer_address"`             // The consumer's blockchain account/address.
	ProducerSignature      string `json:"producer_agreement_signature"` // The producer's signature of the agreement
	BlockchainType         string `json:"blockchain_type"`              // The type of the blockchain that this notification is intended to work with
}

func (MeteringNotification) String

func (m MeteringNotification) String() string

type MicroserviceDefinition

type MicroserviceDefinition struct {
	Id                           string               `json:"record_id"` // unique primary key for records
	Owner                        string               `json:"owner"`
	Label                        string               `json:"label"`
	Description                  string               `json:"description"`
	SpecRef                      string               `json:"specRef"`
	Org                          string               `json:"organization"`
	Version                      string               `json:"version"`
	Arch                         string               `json:"arch"`
	Sharable                     string               `json:"sharable"`
	DownloadURL                  string               `json:"downloadUrl"`
	MatchHardware                HardwareMatch        `json:"matchHardware"`
	UserInputs                   []UserInput          `json:"userInput"`
	Workloads                    []WorkloadDeployment `json:"workloads"`            // Only used by old microservice definitions
	Public                       bool                 `json:"public"`               // Used by only services, indicates if the definition is public or not.
	RequiredServices             []ServiceDependency  `json:"requiredServices"`     // Used only by services, the list of services that this service depends on.
	Deployment                   string               `json:"deployment"`           // Used only by services, the deployment configuration of the implementation packages.
	DeploymentSignature          string               `json:"deployment_signature"` // Used only by services, the signature of the deployment configuration.
	LastUpdated                  string               `json:"lastUpdated"`
	Archived                     bool                 `json:"archived"`
	Name                         string               `json:"name"`                  //the sensor_name passed in from the POST /service call
	RequestedArch                string               `json:"requested_arch"`        //the arch from user input or from the ms referenced by a workload, it can be a synonym of the node arch.
	UpgradeVersionRange          string               `json:"upgrade_version_range"` //the sensor_version passed in from the POST service call
	AutoUpgrade                  bool                 `json:"auto_upgrade"`          // passed in from the POST service call
	ActiveUpgrade                bool                 `json:"active_upgrade"`        // passed in from the POST service call
	UpgradeStartTime             uint64               `json:"upgrade_start_time"`
	UpgradeMsUnregisteredTime    uint64               `json:"upgrade_ms_unregistered_time"`
	UpgradeAgreementsClearedTime uint64               `json:"upgrade_agreements_cleared_time"`
	UpgradeExecutionStartTime    uint64               `json:"upgrade_execution_start_time"`
	UpgradeMsReregisteredTime    uint64               `json:"upgrade_ms_reregistered_time"`
	UpgradeFailedTime            uint64               `json:"upgrade_failed_time"`
	UngradeFailureReason         uint64               `json:"upgrade_failure_reason"`
	UngradeFailureDescription    string               `json:"upgrade_failure_description"`
	UpgradeNewMsId               string               `json:"upgrade_new_ms_id"`
	MetadataHash                 []byte               `json:"metadata_hash"` // the hash of the whole exchange.MicroserviceDefinition

}

func FindMicroserviceDefWithKey

func FindMicroserviceDefWithKey(db *bolt.DB, key string) (*MicroserviceDefinition, error)

find the microservice definition from the db

func FindMicroserviceDefs

func FindMicroserviceDefs(db *bolt.DB, filters []MSFilter) ([]MicroserviceDefinition, error)

find the microservice instance from the db

func FindUnarchivedMicroserviceDefs

func FindUnarchivedMicroserviceDefs(db *bolt.DB, url string, org string) ([]MicroserviceDefinition, error)

find the unarchived microservice definitions for the given url and org

func MSDefNewUpgradeVersionRange

func MSDefNewUpgradeVersionRange(db *bolt.DB, key string, version_range string) (*MicroserviceDefinition, error)

func MSDefUpgradeExecutionStarted

func MSDefUpgradeExecutionStarted(db *bolt.DB, key string) (*MicroserviceDefinition, error)

func MSDefUpgradeFailed

func MSDefUpgradeFailed(db *bolt.DB, key string, reason uint64, reasonString string) (*MicroserviceDefinition, error)

func MSDefUpgradeMsReregistered

func MSDefUpgradeMsReregistered(db *bolt.DB, key string) (*MicroserviceDefinition, error)

func MSDefUpgradeMsUnregistered

func MSDefUpgradeMsUnregistered(db *bolt.DB, key string) (*MicroserviceDefinition, error)

func MSDefUpgradeNewMsId

func MSDefUpgradeNewMsId(db *bolt.DB, key string, new_id string) (*MicroserviceDefinition, error)

func MSDefUpgradeStarted

func MSDefUpgradeStarted(db *bolt.DB, key string) (*MicroserviceDefinition, error)

func MsDefArchived

func MsDefArchived(db *bolt.DB, key string) (*MicroserviceDefinition, error)

set the msdef to archived

func MsDefUnarchived

func MsDefUnarchived(db *bolt.DB, key string) (*MicroserviceDefinition, error)

set the msdef to un-archived

func MsDefUpgradeAgreementsCleared

func MsDefUpgradeAgreementsCleared(db *bolt.DB, key string) (*MicroserviceDefinition, error)

func (*MicroserviceDefinition) GetDeployment

func (m *MicroserviceDefinition) GetDeployment() (string, string)

Returns the deployment string and signature of a ms def.

func (*MicroserviceDefinition) GetUserInputName

func (w *MicroserviceDefinition) GetUserInputName(name string) *UserInput

func (*MicroserviceDefinition) HasDeployment

func (m *MicroserviceDefinition) HasDeployment() bool

func (*MicroserviceDefinition) HasRequiredServices

func (m *MicroserviceDefinition) HasRequiredServices() bool

func (*MicroserviceDefinition) NeedsUserInput

func (m *MicroserviceDefinition) NeedsUserInput() string

func (MicroserviceDefinition) ShortString

func (w MicroserviceDefinition) ShortString() string

func (MicroserviceDefinition) String

func (w MicroserviceDefinition) String() string

type MicroserviceInstance

type MicroserviceInstance struct {
	SpecRef              string                         `json:"ref_url"`
	Org                  string                         `json:"organization"`
	Version              string                         `json:"version"`
	Arch                 string                         `json:"arch"`
	InstanceId           string                         `json:"instance_id"`
	Archived             bool                           `json:"archived"`
	InstanceCreationTime uint64                         `json:"instance_creation_time"`
	ExecutionStartTime   uint64                         `json:"execution_start_time"`
	ExecutionFailureCode uint                           `json:"execution_failure_code"`
	ExecutionFailureDesc string                         `json:"execution_failure_desc"`
	CleanupStartTime     uint64                         `json:"cleanup_start_time"`
	AssociatedAgreements []string                       `json:"associated_agreements"`
	MicroserviceDefId    string                         `json:"microservicedef_id"`
	ParentPath           [][]ServiceInstancePathElement `json:"service_instance_path"` // Set when instance is created
	AgreementLess        bool                           `json:"agreement_less"`        // Set when the service instance was started because it is an agreement-less service (as defined in the pattern)
	MaxRetries           uint                           `json:"max_retries"`           // maximum retries allowed
	MaxRetryDuration     uint                           `json:"max_retry_duration"`    // The number of seconds in which the specified number of retries must occur in order for next retry cycle.
	CurrentRetryCount    uint                           `json:"current_retry_count"`
	RetryStartTime       uint64                         `json:"retry_start_time"`
	EnvVars              map[string]string              `json:"env_vars"`
}

func AgreementToMicroserviceInstance

func AgreementToMicroserviceInstance(ag EstablishedAgreement, msdef_id string) *MicroserviceInstance

Create an microservice instance object out of an agreement. The object is not be saved into the db.

func ArchiveMicroserviceInstance

func ArchiveMicroserviceInstance(db *bolt.DB, key string) (*MicroserviceInstance, error)

func DeleteMicroserviceInstance

func DeleteMicroserviceInstance(db *bolt.DB, key string) (*MicroserviceInstance, error)

delete a microservice instance from db. It will NOT return error if it does not exist in the db

func FindMicroserviceInstance

func FindMicroserviceInstance(db *bolt.DB, url string, org string, version string, instance_id string) (*MicroserviceInstance, error)

find the microservice instance from the db

func FindMicroserviceInstanceWithKey

func FindMicroserviceInstanceWithKey(db *bolt.DB, key string) (*MicroserviceInstance, error)

find the microservice instance from the db

func FindMicroserviceInstances

func FindMicroserviceInstances(db *bolt.DB, filters []MIFilter) ([]MicroserviceInstance, error)

find the microservice instance from the db

func MicroserviceInstanceCleanupStarted

func MicroserviceInstanceCleanupStarted(db *bolt.DB, key string) (*MicroserviceInstance, error)

func NewMicroserviceInstance

func NewMicroserviceInstance(db *bolt.DB, ref_url string, org string, version string, msdef_id string, dependencyPath []ServiceInstancePathElement) (*MicroserviceInstance, error)

create a new microservice instance and save it to db.

func ResetMsInstanceExecutionStatus

func ResetMsInstanceExecutionStatus(db *bolt.DB, key string) (*MicroserviceInstance, error)

func UpdateMSInstanceAddDependencyPath

func UpdateMSInstanceAddDependencyPath(db *bolt.DB, key string, dp *[]ServiceInstancePathElement) (*MicroserviceInstance, error)

Add the given path to the ParentPath. It will not be added if there is duplicate path.

func UpdateMSInstanceAgreementLess

func UpdateMSInstanceAgreementLess(db *bolt.DB, key string) (*MicroserviceInstance, error)

func UpdateMSInstanceAssociatedAgreements

func UpdateMSInstanceAssociatedAgreements(db *bolt.DB, key string, add bool, agreement_id string) (*MicroserviceInstance, error)

add or delete an associated agreement id to/from the microservice instance in the db

func UpdateMSInstanceCurrentRetryCount

func UpdateMSInstanceCurrentRetryCount(db *bolt.DB, key string, current_retry uint) (*MicroserviceInstance, error)

func UpdateMSInstanceEnvVars

func UpdateMSInstanceEnvVars(db *bolt.DB, key string, env_vars map[string]string) (*MicroserviceInstance, error)

func UpdateMSInstanceExecutionState

func UpdateMSInstanceExecutionState(db *bolt.DB, key string, started bool, failure_code uint, failure_desc string) (*MicroserviceInstance, error)

set microservice instance state to execution started or failed

func UpdateMSInstanceRemoveDependencyPath

func UpdateMSInstanceRemoveDependencyPath(db *bolt.DB, key string, dp *[]ServiceInstancePathElement) (*MicroserviceInstance, error)

remove the given path to the ParentPath.

func UpdateMSInstanceRemoveDependencyPath2

func UpdateMSInstanceRemoveDependencyPath2(db *bolt.DB, key string, top_parent *ServiceInstancePathElement) (*MicroserviceInstance, error)

Remove all the paths with the given top parent from the ParentPath

func UpdateMSInstanceRetryState

func UpdateMSInstanceRetryState(db *bolt.DB, key string, started bool, max_retries uint, max_retry_duration uint) (*MicroserviceInstance, error)

This function is call when the retry starts or retry is done. When it is done, this function resets the retry counts

func (*MicroserviceInstance) GetDirectParents

func (m *MicroserviceInstance) GetDirectParents() []ServiceInstancePathElement

It returns a an array of direct parents for this service instance.

func (MicroserviceInstance) GetKey

func (m MicroserviceInstance) GetKey() string

create a unique name for a microservice def If SpecRef is https://bluehorizon.network/microservices/network, Org is myorg, version is 2.3.1 and the instance id is "abcd1234" the output string will be "myorg_bluehorizon.network-microservices-network_2.3.1_abcd1234"

func (*MicroserviceInstance) HasDirectParent

func (m *MicroserviceInstance) HasDirectParent(parent *ServiceInstancePathElement) bool

Check if this microservice instance has the given service as a direct parent.

func (MicroserviceInstance) HasWorkload

func (m MicroserviceInstance) HasWorkload(db *bolt.DB) (bool, error)

Check if this microservice instance has a container dpeloyment. If it does not, then there is no nothing to execute.

func (MicroserviceInstance) String

func (w MicroserviceInstance) String() string

type NativeDeploymentConfig

type NativeDeploymentConfig struct {
	Services map[string]ServiceConfig
}

func (*NativeDeploymentConfig) FromPersistentForm

func (n *NativeDeploymentConfig) FromPersistentForm(pf map[string]interface{}) error

func (*NativeDeploymentConfig) IsNative

func (n *NativeDeploymentConfig) IsNative() bool

func (*NativeDeploymentConfig) ToPersistentForm

func (n *NativeDeploymentConfig) ToPersistentForm() (map[string]interface{}, error)

func (*NativeDeploymentConfig) ToString

func (n *NativeDeploymentConfig) ToString() string

type NodeEventSource

type NodeEventSource struct {
	Id          string `json:"node_id"`
	Org         string `json:"node_org"`
	Pattern     string `json:"pattern"` // fprmat: pattern_org/pattern
	ConfigState string `json:"config_state"`
}

func NewNodeEventSource

func NewNodeEventSource(id string, org string, pattern string, state string) *NodeEventSource

func (NodeEventSource) Matches

func (w NodeEventSource) Matches(selectors map[string][]Selector) bool

func (NodeEventSource) ShortString

func (w NodeEventSource) ShortString() string

func (NodeEventSource) String

func (w NodeEventSource) String() string

type OverwriteCandidateNotFound

type OverwriteCandidateNotFound struct {
	// contains filtered or unexported fields
}

func (OverwriteCandidateNotFound) Error

type Selector

type Selector struct {
	Op         string
	MatchValue interface{}
}

func ConvertToSelectorType

func ConvertToSelectorType(s string) (*Selector, error)

convert the given string to a selecor

type SensorUrls

type SensorUrls struct {
	SensorUrl []string `json:"sensor_url"`
}

This structure is used to get the SensorUrl from the old EstablishedAgreement structure

type ServiceAttribute

type ServiceAttribute interface {
	GetServiceSpecs() *ServiceSpecs
}

type ServiceConfig

type ServiceConfig struct {
	Config     docker.Config     `json:"config"`
	HostConfig docker.HostConfig `json:"host_config"`
}

the internal representation of this lib; *this is the one persisted using the persistence lib*

func (ServiceConfig) String

func (c ServiceConfig) String() string

type ServiceDependency

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

func NewServiceDependency

func NewServiceDependency(url string, org string, version string, arch string) *ServiceDependency

type ServiceEventSource

type ServiceEventSource struct {
	InstanceId           string   `json:"instance_id"`
	ServiceUrl           string   `json:"service_url"`
	Org                  string   `json:"organization"`
	Version              string   `json:"version"`
	Arch                 string   `json:"arch"`
	AssociatedAgreements []string `json:"agreement_id"`
}

purposly made some of the attribute names the same as the AgreementEventSource for easy search.

func NewServiceEventSource

func NewServiceEventSource(instance_id string, service_url string, org string, version string, arch string, agreement_ids []string) *ServiceEventSource

func NewServiceEventSourceFromServiceDef

func NewServiceEventSourceFromServiceDef(msdef MicroserviceDefinition) *ServiceEventSource

func NewServiceEventSourceFromServiceInstance

func NewServiceEventSourceFromServiceInstance(msi MicroserviceInstance) *ServiceEventSource

func (ServiceEventSource) Matches

func (w ServiceEventSource) Matches(selectors map[string][]Selector) bool

Check if this event log matches the input selection.

func (ServiceEventSource) ShortString

func (w ServiceEventSource) ShortString() string

func (ServiceEventSource) String

func (w ServiceEventSource) String() string

type ServiceInstancePathElement

type ServiceInstancePathElement struct {
	URL     string `json:"url"`
	Org     string `json:"org"`
	Version string `json:"version"`
}

func NewServiceInstancePathElement

func NewServiceInstancePathElement(url string, org string, version string) *ServiceInstancePathElement

func (*ServiceInstancePathElement) IsSame

type ServiceSpec

type ServiceSpec struct {
	Url string `json:"url"`
	Org string `json:"organization,omitempty"` // default is the node org
}

func NewServiceSpec

func NewServiceSpec(url string, org string) *ServiceSpec

func (ServiceSpec) IsSame

func (s ServiceSpec) IsSame(sp ServiceSpec) bool

type ServiceSpecs

type ServiceSpecs []ServiceSpec // empty if applicable to all services

func GetAttributeServiceSpecs

func GetAttributeServiceSpecs(attribute *Attribute) *ServiceSpecs

func (*ServiceSpecs) AppendServiceSpec

func (s *ServiceSpecs) AppendServiceSpec(sp ServiceSpec)

important to use this for additions to prevent duplicates and keep slice ordered

func (ServiceSpecs) IsSame

func (s ServiceSpecs) IsSame(sps ServiceSpecs) bool

check if the two service spec arrays point to the same set of services. assume no duplicates in either of the array.

func (ServiceSpecs) SupportService

func (s ServiceSpecs) SupportService(serviceUrl string, serviceOrg string) bool

check if the service attrubute supports the given service If the ServiceSpecs is an empty array, it supports all services. Empty string for service or org means all.

func (*ServiceSpecs) Update

func (s *ServiceSpecs) Update(sps ServiceSpecs)

update the service specs. no duplicates

type SurfaceError

type SurfaceError struct {
	Record_id  string       `json:"record_id"`
	Message    string       `json:"message"`
	Event_code string       `json:"event_code"`
	Hidden     bool         `json:"hidden"`
	Workload   WorkloadInfo `json:"workload"`
	Timestamp  string       `json:"timestamp"`
}

The format for node eventlog errors surfaced to the exchange

func FindSurfaceErrors

func FindSurfaceErrors(db *bolt.DB) ([]SurfaceError, error)

FindSurfaceErrors returns the surface errors currently in the local db

func NewSurfaceError

func NewSurfaceError(eventLog EventLog) SurfaceError

NewSurfaceError returns a surface error from the eventlog parameter

type UserInput

type UserInput struct {
	Name         string `json:"name"`
	Label        string `json:"label"`
	Type         string `json:"type"`
	DefaultValue string `json:"defaultValue"`
}

func NewUserInput

func NewUserInput(name string, label string, stype string, default_value string) *UserInput

type UserInputAttributes

type UserInputAttributes struct {
	Meta         *AttributeMeta         `json:"meta"`
	ServiceSpecs *ServiceSpecs          `json:"service_specs"`
	Mappings     map[string]interface{} `json:"mappings"`
}

func GetAllUserInputAttributes

func GetAllUserInputAttributes(db *bolt.DB) ([]UserInputAttributes, error)

Get all UerInputAttributes from db

func (UserInputAttributes) GetGenericMappings

func (a UserInputAttributes) GetGenericMappings() map[string]interface{}

func (UserInputAttributes) GetMeta

func (a UserInputAttributes) GetMeta() *AttributeMeta

func (UserInputAttributes) GetServiceSpecs

func (a UserInputAttributes) GetServiceSpecs() *ServiceSpecs

func (UserInputAttributes) String

func (a UserInputAttributes) String() string

func (UserInputAttributes) Update

func (a UserInputAttributes) Update(other Attribute) error

type WorkloadDeployment

type WorkloadDeployment struct {
	Deployment          string `json:"deployment"`
	DeploymentSignature string `json:"deployment_signature"`
}

func NewWorkloadDeployment

func NewWorkloadDeployment(deployment string, deploy_sig string) *WorkloadDeployment

type WorkloadInfo

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

func GetWorkloadInfo

func GetWorkloadInfo(eventLog EventLog) WorkloadInfo

func NewWorkloadInfo

func NewWorkloadInfo(url string, org string, version string, arch string) (*WorkloadInfo, error)

Jump to

Keyboard shortcuts

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