Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertToServiceSpecs(apiSpecs policy.APISpecList) persistence.ServiceSpecs
- func MarkI18nMessages()
- type BCInitializedCommand
- type BCStoppingCommand
- type BCWritableCommand
- type BaseProducerProtocolHandler
- func (w *BaseProducerProtocolHandler) FindAgreementWithSameWorkload(ph abstractprotocol.ProtocolHandler, tcpol_name string) (bool, error)
- func (w *BaseProducerProtocolHandler) GetAgbotMessageEndpoint(agbotId string) (string, []byte, error)
- func (c *BaseProducerProtocolHandler) GetKnownBlockchain(ag *persistence.EstablishedAgreement) (string, string, string)
- func (w *BaseProducerProtocolHandler) GetSendMessage() func(mt interface{}, pay []byte) error
- func (w *BaseProducerProtocolHandler) GetServiceResolver() ...
- func (b *BaseProducerProtocolHandler) HandleExtensionMessages(msg *events.ExchangeDeviceMessage, exchangeMsg *exchange.DeviceMessage) (bool, bool, string, error)
- func (w *BaseProducerProtocolHandler) HandleProposal(ph abstractprotocol.ProtocolHandler, proposal abstractprotocol.Proposal, ...) (bool, abstractprotocol.ProposalReply, *policy.Policy)
- func (w *BaseProducerProtocolHandler) MatchPattern(tcPolicy *policy.Policy) (bool, error)
- func (w *BaseProducerProtocolHandler) Name() string
- func (w *BaseProducerProtocolHandler) PersistProposal(proposal abstractprotocol.Proposal, reply abstractprotocol.ProposalReply, ...)
- func (c *BaseProducerProtocolHandler) SetBlockchainClientAvailable(cmd *BCInitializedCommand)
- func (c *BaseProducerProtocolHandler) SetBlockchainClientNotAvailable(cmd *BCStoppingCommand)
- func (w *BaseProducerProtocolHandler) TerminateAgreement(ag *persistence.EstablishedAgreement, reason uint, mt interface{}, ...)
- func (b *BaseProducerProtocolHandler) UpdateConsumer(ag *persistence.EstablishedAgreement)
- func (b *BaseProducerProtocolHandler) UpdateConsumers()
- type BasicProtocolHandler
- func (c *BasicProtocolHandler) AcceptCommand(cmd worker.Command) bool
- func (c *BasicProtocolHandler) AgreementProtocolHandler(typeName string, name string, org string) abstractprotocol.ProtocolHandler
- func (c *BasicProtocolHandler) GetTerminationCode(reason string) uint
- func (c *BasicProtocolHandler) GetTerminationReason(code uint) string
- func (c *BasicProtocolHandler) HandleBlockchainEventMessage(cmd *BlockchainEventCommand) (string, bool, uint64, bool, error)
- func (c *BasicProtocolHandler) HandleExtensionMessages(msg *events.ExchangeDeviceMessage, exchangeMsg *exchange.DeviceMessage) (bool, bool, string, error)
- func (c *BasicProtocolHandler) HandleProposalMessage(proposal abstractprotocol.Proposal, protocolMsg string, ...) bool
- func (c *BasicProtocolHandler) Initialize()
- func (c *BasicProtocolHandler) IsAgreementVerifiable(ag *persistence.EstablishedAgreement) bool
- func (c *BasicProtocolHandler) IsBlockchainClientAvailable(typeName string, name string, org string) bool
- func (c *BasicProtocolHandler) IsBlockchainWritable(agreement *persistence.EstablishedAgreement) bool
- func (c *BasicProtocolHandler) SetBlockchainWritable(cmd *BCWritableCommand)
- func (c *BasicProtocolHandler) String() string
- func (c *BasicProtocolHandler) TerminateAgreement(ag *persistence.EstablishedAgreement, reason uint)
- func (c *BasicProtocolHandler) VerifyAgreement(ag *persistence.EstablishedAgreement) (bool, error)
- type BlockchainEventCommand
- type ExchangeMessageCommand
- type ProducerProtocolHandler
Constants ¶
const ( EL_PROD_AG_EXISTS_IGNORE_PROPOSAL = "Agreement %v already exists, ignoring proposal: %v" EL_PROD_ERR_DEMARSH_TC_FOR_AG = "received error demarshalling TsAndCs for agrement %v, %v" EL_PROD_NODE_REJECTED_PROPOSAL_MSG = "Node received Proposal message using agreement %v for service %v/%v from the agbot %v." EL_PROD_NODE_REJECTED_PROPOSAL = "Node rejected the proposal for service %v/%v." EL_PROD_ERR_HANDLE_PROPOSAL = "Error handling proposal for service %v/%v. Error: %v" )
const TERM_REASON_AGBOT_REQUESTED = "ConsumerCancelled"
const TERM_REASON_CONTAINER_FAILURE = "ContainerFailure"
const TERM_REASON_IMAGE_DATA_ERROR = "ImageDataError"
const TERM_REASON_IMAGE_FETCH_AUTH_FAILURE = "ImageFetchAuthorizationFailure"
const TERM_REASON_IMAGE_FETCH_FAILURE = "ImageFetchFailure"
const TERM_REASON_IMAGE_SIG_VERIF_FAILURE = "ImageSignatureVerificationFailure"
const TERM_REASON_MICROSERVICE_FAILURE = "MicroserviceFailure"
const TERM_REASON_MS_DOWNGRADE_REQUIRED = "MicroserviceDowngradeRequired"
const TERM_REASON_MS_IMAGE_FETCH_FAILURE = "MicroserviceImageFetchFailure"
const TERM_REASON_MS_IMAGE_LOAD_FAILURE = "MicroserviceImageLoadFailure"
const TERM_REASON_MS_UPGRADE_REQUIRED = "MicroserviceUpgradeRequired"
const TERM_REASON_NODE_SHUTDOWN = "NodeShutdown"
const TERM_REASON_NODE_USERINPUT_CHANGED = "NodeUserInputChanged"
const TERM_REASON_NOT_EXECUTED_TIMEOUT = "NotExecuted"
const TERM_REASON_NOT_FINALIZED_TIMEOUT = "NotFinalized"
const TERM_REASON_NO_REPLY_ACK = "NoReplyAck"
const TERM_REASON_POLICY_CHANGED = "PolicyChanged"
The list of termination reasons that should be supported by all agreement protocols. The caller can pass these into the GetTerminationCode API to get a protocol specific reason code for that termination reason.
const TERM_REASON_SERVICE_SUSPENDED = "ServiceSuspended"
const TERM_REASON_USER_REQUESTED = "UserRequested"
const TERM_REASON_WL_IMAGE_LOAD_FAILURE = "WorkloadImageLoadFailure"
Variables ¶
var BPHlogString = func(v interface{}) string { return fmt.Sprintf("Producer Basic Protocol Handler %v", v) }
var BPPHlogString = func(p string, v interface{}) string { return fmt.Sprintf("Base Producer Protocol Handler (%v): %v", p, v) }
Functions ¶
func ConvertToServiceSpecs ¶
func ConvertToServiceSpecs(apiSpecs policy.APISpecList) persistence.ServiceSpecs
This function converts an array of APISpecification to an array of ServiceSpec
func MarkI18nMessages ¶
func MarkI18nMessages()
This is does nothing useful at run time. This code is only used in compileing time to make the eventlog messages gets into the catalog so that they can be translated. The event log messages will be saved in English. But the CLI can request them in different languages.
Types ¶
type BCInitializedCommand ¶
type BCInitializedCommand struct {
Msg *events.BlockchainClientInitializedMessage
}
==============================================================================================================
func NewBCInitializedCommand ¶
func NewBCInitializedCommand(msg *events.BlockchainClientInitializedMessage) *BCInitializedCommand
func (BCInitializedCommand) ShortString ¶
func (c BCInitializedCommand) ShortString() string
type BCStoppingCommand ¶
type BCStoppingCommand struct {
Msg *events.BlockchainClientStoppingMessage
}
==============================================================================================================
func NewBCStoppingCommand ¶
func NewBCStoppingCommand(msg *events.BlockchainClientStoppingMessage) *BCStoppingCommand
func (BCStoppingCommand) ShortString ¶
func (c BCStoppingCommand) ShortString() string
type BCWritableCommand ¶
type BCWritableCommand struct {
Msg events.AccountFundedMessage
}
==============================================================================================================
func NewBCWritableCommand ¶
func NewBCWritableCommand(msg *events.AccountFundedMessage) *BCWritableCommand
func (BCWritableCommand) ShortString ¶
func (c BCWritableCommand) ShortString() string
type BaseProducerProtocolHandler ¶
type BaseProducerProtocolHandler struct {
// contains filtered or unexported fields
}
func (*BaseProducerProtocolHandler) FindAgreementWithSameWorkload ¶
func (w *BaseProducerProtocolHandler) FindAgreementWithSameWorkload(ph abstractprotocol.ProtocolHandler, tcpol_name string) (bool, error)
Check if there are current unarchived agreements that have the same workload.
func (*BaseProducerProtocolHandler) GetAgbotMessageEndpoint ¶
func (w *BaseProducerProtocolHandler) GetAgbotMessageEndpoint(agbotId string) (string, []byte, error)
func (*BaseProducerProtocolHandler) GetKnownBlockchain ¶
func (c *BaseProducerProtocolHandler) GetKnownBlockchain(ag *persistence.EstablishedAgreement) (string, string, string)
func (*BaseProducerProtocolHandler) GetSendMessage ¶
func (w *BaseProducerProtocolHandler) GetSendMessage() func(mt interface{}, pay []byte) error
func (*BaseProducerProtocolHandler) GetServiceResolver ¶
func (w *BaseProducerProtocolHandler) GetServiceResolver() func(wURL string, wOrg string, wVersion string, wArch string) (*policy.APISpecList, error)
func (*BaseProducerProtocolHandler) HandleExtensionMessages ¶
func (b *BaseProducerProtocolHandler) HandleExtensionMessages(msg *events.ExchangeDeviceMessage, exchangeMsg *exchange.DeviceMessage) (bool, bool, string, error)
func (*BaseProducerProtocolHandler) HandleProposal ¶
func (w *BaseProducerProtocolHandler) HandleProposal(ph abstractprotocol.ProtocolHandler, proposal abstractprotocol.Proposal, protocolMsg string, runningBCs []map[string]string, exchangeMsg *exchange.DeviceMessage) (bool, abstractprotocol.ProposalReply, *policy.Policy)
func (*BaseProducerProtocolHandler) MatchPattern ¶
func (w *BaseProducerProtocolHandler) MatchPattern(tcPolicy *policy.Policy) (bool, error)
check if the proposal has the same pattern
func (*BaseProducerProtocolHandler) Name ¶
func (w *BaseProducerProtocolHandler) Name() string
func (*BaseProducerProtocolHandler) PersistProposal ¶
func (w *BaseProducerProtocolHandler) PersistProposal(proposal abstractprotocol.Proposal, reply abstractprotocol.ProposalReply, tcPolicy *policy.Policy, protocolMsg string)
func (*BaseProducerProtocolHandler) SetBlockchainClientAvailable ¶
func (c *BaseProducerProtocolHandler) SetBlockchainClientAvailable(cmd *BCInitializedCommand)
func (*BaseProducerProtocolHandler) SetBlockchainClientNotAvailable ¶
func (c *BaseProducerProtocolHandler) SetBlockchainClientNotAvailable(cmd *BCStoppingCommand)
func (*BaseProducerProtocolHandler) TerminateAgreement ¶
func (w *BaseProducerProtocolHandler) TerminateAgreement(ag *persistence.EstablishedAgreement, reason uint, mt interface{}, pph ProducerProtocolHandler)
func (*BaseProducerProtocolHandler) UpdateConsumer ¶
func (b *BaseProducerProtocolHandler) UpdateConsumer(ag *persistence.EstablishedAgreement)
func (*BaseProducerProtocolHandler) UpdateConsumers ¶
func (b *BaseProducerProtocolHandler) UpdateConsumers()
type BasicProtocolHandler ¶
type BasicProtocolHandler struct { *BaseProducerProtocolHandler // contains filtered or unexported fields }
func NewBasicProtocolHandler ¶
func NewBasicProtocolHandler(name string, cfg *config.HorizonConfig, db *bolt.DB, pm *policy.PolicyManager, ec exchange.ExchangeContext) *BasicProtocolHandler
func (*BasicProtocolHandler) AcceptCommand ¶
func (c *BasicProtocolHandler) AcceptCommand(cmd worker.Command) bool
func (*BasicProtocolHandler) AgreementProtocolHandler ¶
func (c *BasicProtocolHandler) AgreementProtocolHandler(typeName string, name string, org string) abstractprotocol.ProtocolHandler
func (*BasicProtocolHandler) GetTerminationCode ¶
func (c *BasicProtocolHandler) GetTerminationCode(reason string) uint
func (*BasicProtocolHandler) GetTerminationReason ¶
func (c *BasicProtocolHandler) GetTerminationReason(code uint) string
func (*BasicProtocolHandler) HandleBlockchainEventMessage ¶
func (c *BasicProtocolHandler) HandleBlockchainEventMessage(cmd *BlockchainEventCommand) (string, bool, uint64, bool, error)
func (*BasicProtocolHandler) HandleExtensionMessages ¶
func (c *BasicProtocolHandler) HandleExtensionMessages(msg *events.ExchangeDeviceMessage, exchangeMsg *exchange.DeviceMessage) (bool, bool, string, error)
Returns 2 booleans, first is whether or not the message was handled, the second is whether or not to cancel the agreement in the protocol msg.
func (*BasicProtocolHandler) HandleProposalMessage ¶
func (c *BasicProtocolHandler) HandleProposalMessage(proposal abstractprotocol.Proposal, protocolMsg string, exchangeMsg *exchange.DeviceMessage) bool
func (*BasicProtocolHandler) Initialize ¶
func (c *BasicProtocolHandler) Initialize()
func (*BasicProtocolHandler) IsAgreementVerifiable ¶
func (c *BasicProtocolHandler) IsAgreementVerifiable(ag *persistence.EstablishedAgreement) bool
func (*BasicProtocolHandler) IsBlockchainClientAvailable ¶
func (c *BasicProtocolHandler) IsBlockchainClientAvailable(typeName string, name string, org string) bool
func (*BasicProtocolHandler) IsBlockchainWritable ¶
func (c *BasicProtocolHandler) IsBlockchainWritable(agreement *persistence.EstablishedAgreement) bool
func (*BasicProtocolHandler) SetBlockchainWritable ¶
func (c *BasicProtocolHandler) SetBlockchainWritable(cmd *BCWritableCommand)
func (*BasicProtocolHandler) String ¶
func (c *BasicProtocolHandler) String() string
func (*BasicProtocolHandler) TerminateAgreement ¶
func (c *BasicProtocolHandler) TerminateAgreement(ag *persistence.EstablishedAgreement, reason uint)
func (*BasicProtocolHandler) VerifyAgreement ¶
func (c *BasicProtocolHandler) VerifyAgreement(ag *persistence.EstablishedAgreement) (bool, error)
type BlockchainEventCommand ¶
type BlockchainEventCommand struct {
Msg events.EthBlockchainEventMessage
}
==============================================================================================================
func NewBlockchainEventCommand ¶
func NewBlockchainEventCommand(msg events.EthBlockchainEventMessage) *BlockchainEventCommand
func (BlockchainEventCommand) ShortString ¶
func (e BlockchainEventCommand) ShortString() string
type ExchangeMessageCommand ¶
type ExchangeMessageCommand struct {
Msg events.ExchangeDeviceMessage
}
==============================================================================================================
func NewExchangeMessageCommand ¶
func NewExchangeMessageCommand(msg events.ExchangeDeviceMessage) *ExchangeMessageCommand
func (ExchangeMessageCommand) ShortString ¶
func (e ExchangeMessageCommand) ShortString() string
type ProducerProtocolHandler ¶
type ProducerProtocolHandler interface { Initialize() Name() string AcceptCommand(cmd worker.Command) bool AgreementProtocolHandler(typeName string, name string, org string) abstractprotocol.ProtocolHandler HandleProposalMessage(proposal abstractprotocol.Proposal, protocolMsg string, exchangeMsg *exchange.DeviceMessage) bool HandleBlockchainEventMessage(cmd *BlockchainEventCommand) (string, bool, uint64, bool, error) TerminateAgreement(agreement *persistence.EstablishedAgreement, reason uint) GetSendMessage() func(mt interface{}, pay []byte) error GetTerminationCode(reason string) uint GetTerminationReason(code uint) string SetBlockchainClientAvailable(cmd *BCInitializedCommand) SetBlockchainClientNotAvailable(cmd *BCStoppingCommand) IsBlockchainClientAvailable(typeName string, name string, org string) bool SetBlockchainWritable(cmd *BCWritableCommand) IsBlockchainWritable(agreement *persistence.EstablishedAgreement) bool IsAgreementVerifiable(agreement *persistence.EstablishedAgreement) bool HandleExtensionMessages(msg *events.ExchangeDeviceMessage, exchangeMsg *exchange.DeviceMessage) (bool, bool, string, error) UpdateConsumer(ag *persistence.EstablishedAgreement) UpdateConsumers() GetKnownBlockchain(ag *persistence.EstablishedAgreement) (string, string, string) VerifyAgreement(ag *persistence.EstablishedAgreement) (bool, error) }
func CreateProducerPH ¶
func CreateProducerPH(name string, cfg *config.HorizonConfig, db *bolt.DB, pm *policy.PolicyManager, ec exchange.ExchangeContext) ProducerProtocolHandler