Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveAgreementsContains(activeAgreements []string, agreement persistence.Agreement, prefix string) bool
- func AssignObjectToNode(ec exchange.ExchangeContext, objPolicies *exchange.ObjectDestinationPolicies, ...) error
- func DeleteConsumerAgreement(httpClient *http.Client, url string, agbotId string, token string, ...) error
- func DeleteMessage(msgId int, agbotId, agbotToken, exchangeURL string, httpClient *http.Client) error
- func FindCompatibleServices(agreementServiceID string, objPol *exchange.ObjectDestinationPolicy, ...) (bool, error)
- func GetActiveAgreements(in_devices map[string][]string, agreement persistence.Agreement, ...) ([]string, error)
- func GetDevice(httpClient *http.Client, deviceId string, url string, agbotId string, ...) (*exchange.Device, error)
- func GetNodePolicy(ec exchange.ExchangeContext, deviceId string) (*policy.Policy, error)
- func Invoke_rest(client *http.Client, method string, url string, user string, pw string, ...) error
- func RetrieveAllProperties(version string, arch string, pol *policy.Policy) (*externalpolicy.PropertyList, error)
- func SupportsArch(objPolServiceID *common.ServiceID, serviceArch string, ...) bool
- func SupportsVersion(objPolServiceID *common.ServiceID, serviceVersion string) (bool, error)
- func UnassignObjectFromNode(ec exchange.ExchangeContext, objPol *exchange.ObjectDestinationPolicy, ...) error
- type API
- func (a *API) GetCSSURL() string
- func (a *API) GetExchangeId() string
- func (a *API) GetExchangeToken() string
- func (a *API) GetExchangeURL() string
- func (a *API) GetHTTPFactory() *config.HTTPClientFactory
- func (a *API) GetHorizonAgbotConfig() (*HorizonAgbotConfig, error)
- func (a *API) GetName() string
- func (a *API) Messages() chan events.Message
- func (a *API) NewEvent(ev events.Message)
- type APIUserInputError
- type AccountFundedCommand
- type AgbotShutdownCommand
- type AgreementBotWorker
- func (w *AgreementBotWorker) CommandHandler(command worker.Command) bool
- func (w *AgreementBotWorker) GeneratePolicies() int
- func (w *AgreementBotWorker) GovernAgreements() int
- func (w *AgreementBotWorker) GovernArchivedAgreements() int
- func (w *AgreementBotWorker) GovernBlockchainNeeds() int
- func (w *AgreementBotWorker) Initialize() bool
- func (w *AgreementBotWorker) Messages() chan events.Message
- func (w *AgreementBotWorker) NewEvent(incoming events.Message)
- func (w *AgreementBotWorker) NoWorkHandler()
- func (w *AgreementBotWorker) ShutdownStarted() bool
- func (w *AgreementBotWorker) TerminateAgreement(ag *persistence.Agreement, reason uint)
- func (w *AgreementBotWorker) VerifyNodeHealth(ag *persistence.Agreement, cph ConsumerProtocolHandler) (int, error)
- type AgreementEntry
- type AgreementLockManager
- type AgreementTimeoutCommand
- type AgreementWork
- type AgreementWorker
- type AgreementsByAgreementCreationTime
- type AgreementsByAgreementTimeoutTime
- type AsyncCancelAgreement
- type BAgreementVerification
- type BAgreementVerificationReply
- type BaseAgreementWorker
- func (b *BaseAgreementWorker) AgreementLockManager() *AgreementLockManager
- func (b *BaseAgreementWorker) CancelAgreement(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string) bool
- func (b *BaseAgreementWorker) CancelAgreementWithLock(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string) bool
- func (b *BaseAgreementWorker) DoAsyncCancel(cph ConsumerProtocolHandler, ag *persistence.Agreement, reason uint, ...)
- func (b *BaseAgreementWorker) ExternalCancel(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string)
- func (b *BaseAgreementWorker) GetCSSURL() string
- func (b *BaseAgreementWorker) GetExchangeId() string
- func (b *BaseAgreementWorker) GetExchangeToken() string
- func (b *BaseAgreementWorker) GetExchangeURL() string
- func (b *BaseAgreementWorker) GetHTTPFactory() *config.HTTPClientFactory
- func (b *BaseAgreementWorker) GetMergedProducerPolicyForPattern(deviceId string, dev *exchange.Device, asl policy.APISpecList) (*policy.Policy, error)
- func (b *BaseAgreementWorker) GetServicePolicy(svcId string) (*externalpolicy.ExternalPolicy, error)
- func (b *BaseAgreementWorker) HandleAgreementReply(cph ConsumerProtocolHandler, wi *HandleReply, workerId string) bool
- func (b *BaseAgreementWorker) HandleDataReceivedAck(cph ConsumerProtocolHandler, wi *HandleDataReceivedAck, workerId string)
- func (w *BaseAgreementWorker) HandleMMSObjectPolicy(cph ConsumerProtocolHandler, wi *ObjectPolicyChange, workerId string)
- func (b *BaseAgreementWorker) HandleWorkloadUpgrade(cph ConsumerProtocolHandler, wi *HandleWorkloadUpgrade, workerId string)
- func (b *BaseAgreementWorker) InitiateNewAgreement(cph ConsumerProtocolHandler, wi *InitiateAgreement, random *rand.Rand, ...)
- func (b *BaseAgreementWorker) MergeServicePolicyToConsumerPolicy(businessPol *policy.Policy, builtInSvcPol *externalpolicy.ExternalPolicy, ...) (*policy.Policy, *externalpolicy.ExternalPolicy, error)
- func (b *BaseAgreementWorker) VerifyUserInputForService(svcName, svcOrg, svcVersion, svcArch string, default_input []policy.UserInput, ...) error
- func (b *BaseAgreementWorker) VerifyUserInputForServiceDef(sdef *exchange.ServiceDefinition, svcOrg string, ...) error
- type BaseConsumerProtocolHandler
- func (c *BaseConsumerProtocolHandler) AlreadyReceivedReply(ag *persistence.Agreement) bool
- func (c *BaseConsumerProtocolHandler) CanSendMeterRecord(ag *persistence.Agreement) bool
- func (b *BaseConsumerProtocolHandler) CancelAgreement(ag persistence.Agreement, reason string, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) DeferCommand(cmd AgreementWork)
- func (b *BaseConsumerProtocolHandler) DeleteMessage(msgId int) error
- func (b *BaseConsumerProtocolHandler) DispatchProtocolMessage(cmd *NewProtocolMessageCommand, cph ConsumerProtocolHandler) error
- func (b *BaseConsumerProtocolHandler) GetCSSURL() string
- func (b *BaseConsumerProtocolHandler) GetDeferredCommands() []AgreementWork
- func (b *BaseConsumerProtocolHandler) GetDeviceMessageEndpoint(deviceId string, workerId string) (string, []byte, error)
- func (b *BaseConsumerProtocolHandler) GetExchangeId() string
- func (b *BaseConsumerProtocolHandler) GetExchangeToken() string
- func (b *BaseConsumerProtocolHandler) GetExchangeURL() string
- func (b *BaseConsumerProtocolHandler) GetHTTPFactory() *config.HTTPClientFactory
- func (c *BaseConsumerProtocolHandler) GetKnownBlockchain(ag *persistence.Agreement) (string, string, string)
- func (b *BaseConsumerProtocolHandler) GetSendMessage() func(mt interface{}, pay []byte) error
- func (b *BaseConsumerProtocolHandler) GetServiceBased() bool
- func (b *BaseConsumerProtocolHandler) HandleAgreementTimeout(cmd *AgreementTimeoutCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleExtensionMessage(cmd *NewProtocolMessageCommand) error
- func (b *BaseConsumerProtocolHandler) HandleMMSObjectPolicy(cmd *MMSObjectPolicyEventCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleMakeAgreement(cmd *MakeAgreementCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandlePolicyChanged(cmd *PolicyChangedCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandlePolicyDeleted(cmd *PolicyDeletedCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleServicePolicyChanged(cmd *ServicePolicyChangedCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleServicePolicyDeleted(cmd *ServicePolicyDeletedCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleStopProtocol(cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) HandleWorkloadUpgrade(cmd *WorkloadUpgradeCommand, cph ConsumerProtocolHandler)
- func (b *BaseConsumerProtocolHandler) Name() string
- func (b *BaseConsumerProtocolHandler) PersistBaseAgreement(wi *InitiateAgreement, proposal abstractprotocol.Proposal, workerID string, ...) error
- func (b *BaseConsumerProtocolHandler) PersistReply(reply abstractprotocol.ProposalReply, pol *policy.Policy, workerID string) error
- func (b *BaseConsumerProtocolHandler) RecordConsumerAgreementState(agreementId string, pol *policy.Policy, org string, state string, ...) error
- func (b *BaseConsumerProtocolHandler) SendEventMessage(event events.Message)
- func (c *BaseConsumerProtocolHandler) SetBlockchainClientAvailable(ev *events.BlockchainClientInitializedMessage)
- func (c *BaseConsumerProtocolHandler) SetBlockchainClientNotAvailable(ev *events.BlockchainClientStoppingMessage)
- func (b *BaseConsumerProtocolHandler) TerminateAgreement(ag *persistence.Agreement, reason uint, mt interface{}, workerId string, ...)
- func (b *BaseConsumerProtocolHandler) UpdateProducer(ag *persistence.Agreement)
- func (b *BaseConsumerProtocolHandler) VerifyAgreement(ag *persistence.Agreement, cph ConsumerProtocolHandler)
- type BasicAgreementWorker
- 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) CanCancelNow(ag *persistence.Agreement) bool
- func (c *BasicProtocolHandler) CreateMeteringNotification(mp policy.Meter, ag *persistence.Agreement) (*metering.MeteringNotification, error)
- func (c *BasicProtocolHandler) GetTerminationCode(reason string) uint
- func (c *BasicProtocolHandler) GetTerminationReason(code uint) string
- func (c *BasicProtocolHandler) HandleBlockchainEvent(cmd *BlockchainEventCommand)
- func (c *BasicProtocolHandler) HandleDeferredCommands()
- func (b *BasicProtocolHandler) HandleExtensionMessage(cmd *NewProtocolMessageCommand) error
- func (c *BasicProtocolHandler) Initialize()
- func (c *BasicProtocolHandler) IsBlockchainWritable(typeName string, name string, org string) bool
- func (c *BasicProtocolHandler) IsTerminationReasonNodeShutdown(code uint) bool
- func (c *BasicProtocolHandler) PersistAgreement(wi *InitiateAgreement, proposal abstractprotocol.Proposal, workerID string) error
- func (c *BasicProtocolHandler) PersistReply(r abstractprotocol.ProposalReply, pol *policy.Policy, workerID string) error
- func (b *BasicProtocolHandler) PostReply(agreementId string, proposal abstractprotocol.Proposal, ...) error
- func (c *BasicProtocolHandler) SetBlockchainWritable(ev *events.AccountFundedMessage)
- func (c *BasicProtocolHandler) String() string
- func (c *BasicProtocolHandler) TerminateAgreement(ag *persistence.Agreement, reason uint, workerId string)
- func (c *BasicProtocolHandler) WorkQueue() chan AgreementWork
- type BlockchainEventCommand
- type BusinessPolicyEntry
- func (p *BusinessPolicyEntry) AddServicePolicy(svcPolicy *externalpolicy.ExternalPolicy, svcId string) (bool, error)
- func (pe *BusinessPolicyEntry) DeleteAllServicePolicies(org string)
- func (p *BusinessPolicyEntry) RemoveServicePolicy(svcId string) bool
- func (p *BusinessPolicyEntry) ShortString() string
- func (p *BusinessPolicyEntry) String() string
- func (p *BusinessPolicyEntry) UpdateEntry(pol *businesspolicy.BusinessPolicy, polId string, newHash []byte) (*policy.Policy, error)
- type BusinessPolicyManager
- func (pm *BusinessPolicyManager) AddMarshaledServicePolicy(businessPolOrg, businessPolName, serviceId, servicePolString string) error
- func (pm *BusinessPolicyManager) AddServicePolicy(businessPolOrg string, businessPolName string, serviceId string, ...) error
- func (pm *BusinessPolicyManager) GetAllBusinessPolicyEntriesForOrg(org string) map[string]*BusinessPolicyEntry
- func (pm *BusinessPolicyManager) GetAllPolicyOrgs() []string
- func (pm *BusinessPolicyManager) GetBusinessPolicyEntry(org string, pol *policy.Policy) *BusinessPolicyEntry
- func (pm *BusinessPolicyManager) GetServedNodeOrgs(polOrg string, polName string) []string
- func (pm *BusinessPolicyManager) GetServicePoliciesForPolicy(org string, polName string) map[string]externalpolicy.ExternalPolicy
- func (pm *BusinessPolicyManager) RemoveServicePolicy(businessPolOrg string, businessPolName string, serviceId string) error
- func (pm *BusinessPolicyManager) SetCurrentBusinessPolicies(servedPols map[string]exchange.ServedBusinessPolicy, ...) error
- func (pm *BusinessPolicyManager) ShortString() string
- func (pm *BusinessPolicyManager) String() string
- func (pm *BusinessPolicyManager) UpdatePolicies(org string, definedPolicies map[string]exchange.ExchangeBusinessPolicy, ...) error
- type CacheServicePolicyCommand
- type CancelAgreement
- type ClientInitializedCommand
- type ClientStoppingCommand
- type ConsumerProtocolHandler
- type DVState
- type DeviceEntry
- type HandleDataReceivedAck
- type HandleReply
- type HandleWorkloadUpgrade
- type HorizonAgbot
- type HorizonAgbotConfig
- type InitiateAgreement
- type MMSObjectPolicyEntry
- type MMSObjectPolicyEventCommand
- type MMSObjectPolicyManager
- func (m *MMSObjectPolicyManager) GetAllPolicyOrgs() []string
- func (m *MMSObjectPolicyManager) GetObjectPolicies(org string, serviceName string, arch string, version string) *exchange.ObjectDestinationPolicies
- func (m *MMSObjectPolicyManager) NewMMSObjectPolicyEntry(pol *exchange.ObjectDestinationPolicy, serviceID common.ServiceID, ...) *MMSObjectPolicyEntry
- func (m *MMSObjectPolicyManager) SetCurrentPolicyOrgs(servedPols map[string]exchange.ServedBusinessPolicy) error
- func (m *MMSObjectPolicyManager) String() string
- func (m *MMSObjectPolicyManager) UpdatePolicies(org string, updatedPolicies *exchange.ObjectDestinationPolicies, ...) ([]events.Message, error)
- type MakeAgreementCommand
- type NHPatternEntry
- type NewProtocolMessageCommand
- type NodeHealthHandler
- type NodeHealthManager
- func (m *NodeHealthManager) AgreementOutOfPolicy(pattern string, org string, deviceId string, agreementId string, start uint64, ...) bool
- func (m *NodeHealthManager) NodeOutOfPolicy(pattern string, org string, deviceId string, interval int) bool
- func (m *NodeHealthManager) ResetUpdateStatus()
- func (m *NodeHealthManager) SetNodeOrgs(agreements []persistence.Agreement, agreementProtocol string)
- func (m *NodeHealthManager) SetUpdatedStatus(pattern string, org string, nhHandler NodeHealthHandler) error
- func (n *NodeHealthManager) String() string
- type ObjectPolicyChange
- type PatternEntry
- func (pe *PatternEntry) AddPolicyFileName(fileName string)
- func (pe *PatternEntry) DeleteAllPolicyFiles(policyPath string, org string) error
- func (p *PatternEntry) ShortString() string
- func (p *PatternEntry) String() string
- func (pe *PatternEntry) UpdateEntry(pattern *exchange.Pattern, newHash []byte)
- type PatternManager
- func (pm *PatternManager) GetServedNodeOrgs(pattten_org string, pattern string) []string
- func (pm *PatternManager) SetCurrentPatterns(servedPatterns map[string]exchange.ServedPattern, policyPath string) error
- func (p *PatternManager) ShortString() string
- func (pm *PatternManager) String() string
- func (pm *PatternManager) UpdatePatternPolicies(org string, definedPatterns map[string]exchange.Pattern, policyPath string) error
- type PolicyChangedCommand
- type PolicyDeletedCommand
- type ServicePolicyChangedCommand
- type ServicePolicyDeletedCommand
- type ServicePolicyEntry
- type StopWorker
- type UpgradeDevice
- type WorkloadUpgradeCommand
- type WorkloadUsagesByDeviceId
Constants ¶
const AGREEMENT_VERIFICATION = "AGREEMENT_VERIFY"
These are work items that represent extensions to the protocol.
const AGREEMENT_VERIFICATION_REPLY = "AGREEMENT_VERIFY_REPLY"
These are work items that represent extensions to the protocol.
const ASYNC_CANCEL = "ASYNC_CANCEL"
const CANCEL = "AGREEMENT_CANCEL"
const DATABASE_HEARTBEAT = "AgbotDatabaseHeartBeat"
const DATARECEIVEDACK = "AGREEMENT_DATARECEIVED_ACK"
const GENERATE_POLICY = "AgBotPolicyGenerator"
const GOVERN_AGREEMENTS = "AgBotGovernAgreements"
const GOVERN_ARCHIVED_AGREEMENTS = "AgBotGovernArchivedAgreements"
const GOVERN_BC_NEEDS = "AgBotGovernBlockchain"
const HEARTBEAT = "AgbotHeartBeat"
for identifying the subworkers used by this worker
const INITIATE = "INITIATE_AGREEMENT"
These structs are the event bodies that flow from the processor to the agreement workers
const MESSAGE_KEY_CHECK = "AgbotMessageKeyCheck"
const MMS_OBJECT_POLICY = "MMS_OBJECT_POLICY"
const POLICY_WATCHER = "AgBotPolicyWatcher"
const REPLY = "AGREEMENT_REPLY"
const STALE_PARTITIONS = "AgbotStaleDatabasePartition"
const STOP = "PROTOCOL_WORKER_STOP"
const TERM_REASON_AG_MISSING = "AgreementMissing"
const TERM_REASON_CANCEL_BC_WRITE_FAILED = "WriteFailed"
const TERM_REASON_CANCEL_DISCOVERED = "CancelDiscovered"
const TERM_REASON_CANCEL_FORCED_UPGRADE = "ForceUpgrade"
const TERM_REASON_DEVICE_REQUESTED = "DeviceRequested"
const TERM_REASON_NEGATIVE_REPLY = "NegativeReply"
const TERM_REASON_NODE_HEARTBEAT = "NodeHeartbeat"
const TERM_REASON_NOT_FINALIZED_TIMEOUT = "NotFinalized"
const TERM_REASON_NO_DATA_RECEIVED = "NoData"
const TERM_REASON_NO_REPLY = "NoReply"
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_USER_REQUESTED = "UserRequested"
const WORKLOAD_UPGRADE = "WORKLOAD_UPGRADE"
Variables ¶
var APIlogString = func(v interface{}) string { return fmt.Sprintf("AgreementBotWorker API %v", v) }
Log string prefix api
var AWlogString = func(v interface{}) string { return fmt.Sprintf("AgreementBotWorker %v", v) }
var BAWlogstring = func(workerID string, v interface{}) string { return fmt.Sprintf("Base Agreement Worker (%v): %v", workerID, v) }
var BCPHlogstring = func(p string, v interface{}) string { return fmt.Sprintf("Base Consumer Protocol Handler (%v) %v", p, v) }
var BCPHlogstring2 = func(workerID string, v interface{}) string { return fmt.Sprintf("Base Consumer Protocol Handler (%v): %v", workerID, v) }
var BsCPHlogString = func(v interface{}) string { return fmt.Sprintf("AgreementBot Basic Protocol Handler %v", v) }
Functions ¶
func ActiveAgreementsContains ¶
func ActiveAgreementsContains(activeAgreements []string, agreement persistence.Agreement, prefix string) bool
func AssignObjectToNode ¶
func AssignObjectToNode(ec exchange.ExchangeContext, objPolicies *exchange.ObjectDestinationPolicies, nodeId string, nodePolicy *policy.Policy) error
func DeleteConsumerAgreement ¶
func DeleteMessage ¶
func FindCompatibleServices ¶
func FindCompatibleServices(agreementServiceID string, objPol *exchange.ObjectDestinationPolicy, workerId string, archSynonyms config.ArchSynonyms) (bool, error)
This function returns true if the input agreement service id is compatible with one of the service IDs in the object's policy.
func GetActiveAgreements ¶
func GetActiveAgreements(in_devices map[string][]string, agreement persistence.Agreement, hConfig *config.HorizonConfig) ([]string, error)
func GetNodePolicy ¶
Get node policy
func Invoke_rest ¶
func RetrieveAllProperties ¶
func RetrieveAllProperties(version string, arch string, pol *policy.Policy) (*externalpolicy.PropertyList, error)
This function runs through the agbot policy and builds a list of properties and values that it wants to search on.
func SupportsArch ¶
func SupportsVersion ¶
func UnassignObjectFromNode ¶
func UnassignObjectFromNode(ec exchange.ExchangeContext, objPol *exchange.ObjectDestinationPolicy, nodeId string) error
Types ¶
type API ¶
type API struct { worker.Manager // embedded field EC *worker.BaseExchangeContext // contains filtered or unexported fields }
func NewAPIListener ¶
func NewAPIListener(name string, config *config.HorizonConfig, db persistence.AgbotDatabase, configFile string) *API
func (*API) GetExchangeId ¶
A local implementation of the ExchangeContext interface because the API object is not an anax worker.
func (*API) GetExchangeToken ¶
func (*API) GetExchangeURL ¶
func (*API) GetHTTPFactory ¶
func (a *API) GetHTTPFactory() *config.HTTPClientFactory
func (*API) GetHorizonAgbotConfig ¶
func (a *API) GetHorizonAgbotConfig() (*HorizonAgbotConfig, error)
type APIUserInputError ¶
type AccountFundedCommand ¶
type AccountFundedCommand struct {
Msg events.AccountFundedMessage
}
==============================================================================================================
func NewAccountFundedCommand ¶
func NewAccountFundedCommand(msg *events.AccountFundedMessage) *AccountFundedCommand
func (AccountFundedCommand) ShortString ¶
func (e AccountFundedCommand) ShortString() string
type AgbotShutdownCommand ¶
type AgbotShutdownCommand struct {
Msg events.NodeShutdownMessage
}
==============================================================================================================
func NewAgbotShutdownCommand ¶
func NewAgbotShutdownCommand(msg *events.NodeShutdownMessage) *AgbotShutdownCommand
func (AgbotShutdownCommand) ShortString ¶
func (e AgbotShutdownCommand) ShortString() string
type AgreementBotWorker ¶
type AgreementBotWorker struct { worker.BaseWorker // embedded field PatternManager *PatternManager BusinessPolManager *BusinessPolicyManager NHManager *NodeHealthManager GovTiming DVState MMSObjectPM *MMSObjectPolicyManager // contains filtered or unexported fields }
must be safely-constructed!!
func NewAgreementBotWorker ¶
func NewAgreementBotWorker(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase) *AgreementBotWorker
func (*AgreementBotWorker) CommandHandler ¶
func (w *AgreementBotWorker) CommandHandler(command worker.Command) bool
func (*AgreementBotWorker) GeneratePolicies ¶
func (w *AgreementBotWorker) GeneratePolicies() int
Generate policies. 1. generate policy files based on pattern metadata in the exchange. 2. generate policies in memory on business metadata in the exchange. 3. capture object destination policies in memory from the MMS. This happens within #2. The return value from this function is the length of time the caller should wait before calling again. If -1 is returned, there was an error.
func (*AgreementBotWorker) GovernAgreements ¶
func (w *AgreementBotWorker) GovernAgreements() int
func (*AgreementBotWorker) GovernArchivedAgreements ¶
func (w *AgreementBotWorker) GovernArchivedAgreements() int
Govern the archived agreements, periodically deleting them from the database if they are old enough. The age limit is defined by the agbot configuration, PurgeArchivedAgreementHours.
func (*AgreementBotWorker) GovernBlockchainNeeds ¶
func (w *AgreementBotWorker) GovernBlockchainNeeds() int
Govern the active agreements, reporting which ones need a blockchain running so that the blockchain workers can keep them running.
func (*AgreementBotWorker) Initialize ¶
func (w *AgreementBotWorker) Initialize() bool
func (*AgreementBotWorker) Messages ¶
func (w *AgreementBotWorker) Messages() chan events.Message
func (*AgreementBotWorker) NewEvent ¶
func (w *AgreementBotWorker) NewEvent(incoming events.Message)
func (*AgreementBotWorker) NoWorkHandler ¶
func (w *AgreementBotWorker) NoWorkHandler()
func (*AgreementBotWorker) ShutdownStarted ¶
func (w *AgreementBotWorker) ShutdownStarted() bool
func (*AgreementBotWorker) TerminateAgreement ¶
func (w *AgreementBotWorker) TerminateAgreement(ag *persistence.Agreement, reason uint)
func (*AgreementBotWorker) VerifyNodeHealth ¶
func (w *AgreementBotWorker) VerifyNodeHealth(ag *persistence.Agreement, cph ConsumerProtocolHandler) (int, error)
This function is used to verify that a node is still functioning correctly
type AgreementEntry ¶
type AgreementLockManager ¶
type AgreementLockManager struct { MapLock sync.Mutex // The lock that protects the map of agreement locks AgreementMapLocks map[string]*sync.Mutex // A map of locks by agreement id }
func NewAgreementLockManager ¶
func NewAgreementLockManager() *AgreementLockManager
type AgreementTimeoutCommand ¶
==============================================================================================================
func NewAgreementTimeoutCommand ¶
func NewAgreementTimeoutCommand(agreementId string, protocol string, reason uint) *AgreementTimeoutCommand
func (AgreementTimeoutCommand) ShortString ¶
func (a AgreementTimeoutCommand) ShortString() string
type AgreementWork ¶
type AgreementWork interface {
Type() string
}
type AgreementWorker ¶
type AgreementWorker interface {
AgreementLockManager() *AgreementLockManager
}
type AgreementsByAgreementCreationTime ¶
type AgreementsByAgreementCreationTime []persistence.Agreement
Helper functions for sorting agreements
func (AgreementsByAgreementCreationTime) Len ¶
func (s AgreementsByAgreementCreationTime) Len() int
func (AgreementsByAgreementCreationTime) Less ¶
func (s AgreementsByAgreementCreationTime) Less(i, j int) bool
func (AgreementsByAgreementCreationTime) Swap ¶
func (s AgreementsByAgreementCreationTime) Swap(i, j int)
type AgreementsByAgreementTimeoutTime ¶
type AgreementsByAgreementTimeoutTime []persistence.Agreement
func (AgreementsByAgreementTimeoutTime) Len ¶
func (s AgreementsByAgreementTimeoutTime) Len() int
func (AgreementsByAgreementTimeoutTime) Less ¶
func (s AgreementsByAgreementTimeoutTime) Less(i, j int) bool
func (AgreementsByAgreementTimeoutTime) Swap ¶
func (s AgreementsByAgreementTimeoutTime) Swap(i, j int)
type AsyncCancelAgreement ¶
type AsyncCancelAgreement struct { AgreementId string Protocol string Reason uint // contains filtered or unexported fields }
func (AsyncCancelAgreement) Type ¶
func (c AsyncCancelAgreement) Type() string
type BAgreementVerification ¶
type BAgreementVerification struct { Verify basicprotocol.BAgreementVerify From string // deprecated whisper address SenderId string // exchange Id of sender SenderPubKey []byte MessageId int // contains filtered or unexported fields }
func (BAgreementVerification) String ¶
func (b BAgreementVerification) String() string
func (BAgreementVerification) Type ¶
func (b BAgreementVerification) Type() string
type BAgreementVerificationReply ¶
type BAgreementVerificationReply struct { VerifyReply basicprotocol.BAgreementVerifyReply From string // deprecated whisper address SenderId string // exchange Id of sender SenderPubKey []byte MessageId int // contains filtered or unexported fields }
func (BAgreementVerificationReply) String ¶
func (b BAgreementVerificationReply) String() string
func (BAgreementVerificationReply) Type ¶
func (b BAgreementVerificationReply) Type() string
type BaseAgreementWorker ¶
type BaseAgreementWorker struct {
// contains filtered or unexported fields
}
func (*BaseAgreementWorker) AgreementLockManager ¶
func (b *BaseAgreementWorker) AgreementLockManager() *AgreementLockManager
func (*BaseAgreementWorker) CancelAgreement ¶
func (b *BaseAgreementWorker) CancelAgreement(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string) bool
func (*BaseAgreementWorker) CancelAgreementWithLock ¶
func (b *BaseAgreementWorker) CancelAgreementWithLock(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string) bool
func (*BaseAgreementWorker) DoAsyncCancel ¶
func (b *BaseAgreementWorker) DoAsyncCancel(cph ConsumerProtocolHandler, ag *persistence.Agreement, reason uint, workerId string)
func (*BaseAgreementWorker) ExternalCancel ¶
func (b *BaseAgreementWorker) ExternalCancel(cph ConsumerProtocolHandler, agreementId string, reason uint, workerId string)
func (*BaseAgreementWorker) GetCSSURL ¶
func (b *BaseAgreementWorker) GetCSSURL() string
func (*BaseAgreementWorker) GetExchangeId ¶
func (b *BaseAgreementWorker) GetExchangeId() string
A local implementation of the ExchangeContext interface because Agbot agreement workers are not full featured workers.
func (*BaseAgreementWorker) GetExchangeToken ¶
func (b *BaseAgreementWorker) GetExchangeToken() string
func (*BaseAgreementWorker) GetExchangeURL ¶
func (b *BaseAgreementWorker) GetExchangeURL() string
func (*BaseAgreementWorker) GetHTTPFactory ¶
func (b *BaseAgreementWorker) GetHTTPFactory() *config.HTTPClientFactory
func (*BaseAgreementWorker) GetMergedProducerPolicyForPattern ¶
func (b *BaseAgreementWorker) GetMergedProducerPolicyForPattern(deviceId string, dev *exchange.Device, asl policy.APISpecList) (*policy.Policy, error)
get the merged producer policy. asl is the spec list for the dependent services for a top level service.
func (*BaseAgreementWorker) GetServicePolicy ¶
func (b *BaseAgreementWorker) GetServicePolicy(svcId string) (*externalpolicy.ExternalPolicy, error)
Get service policy
func (*BaseAgreementWorker) HandleAgreementReply ¶
func (b *BaseAgreementWorker) HandleAgreementReply(cph ConsumerProtocolHandler, wi *HandleReply, workerId string) bool
func (*BaseAgreementWorker) HandleDataReceivedAck ¶
func (b *BaseAgreementWorker) HandleDataReceivedAck(cph ConsumerProtocolHandler, wi *HandleDataReceivedAck, workerId string)
func (*BaseAgreementWorker) HandleMMSObjectPolicy ¶
func (w *BaseAgreementWorker) HandleMMSObjectPolicy(cph ConsumerProtocolHandler, wi *ObjectPolicyChange, workerId string)
MMS object policy changes can cause a significant impact to where objects are placed through the entire system. When an MMS object policy changes, it might mean one of the following:
- Nothing changes. a. A brand new policy is not eligible for any node on which there is already an agreement. b. A policy change is still not sufficent to make the object eligible for nodes that are already in an agreement.
- There are nodes on which the object should be removed.
- There are nodes on which the object should be placed, where there is already an agreement. a. A new object/policy is placed on the node long after the agreement is in place. b. A policy change makes the object eligible for the node long after the agreement is in place.
Objects are not placed on nodes without an agreement, so we can find all the relevant nodes by looking through all of our agreements. The actions we can take are to either remove a node from the destination list of a policy or add it to the object's destination list.
func (*BaseAgreementWorker) HandleWorkloadUpgrade ¶
func (b *BaseAgreementWorker) HandleWorkloadUpgrade(cph ConsumerProtocolHandler, wi *HandleWorkloadUpgrade, workerId string)
func (*BaseAgreementWorker) InitiateNewAgreement ¶
func (b *BaseAgreementWorker) InitiateNewAgreement(cph ConsumerProtocolHandler, wi *InitiateAgreement, random *rand.Rand, workerId string)
func (*BaseAgreementWorker) MergeServicePolicyToConsumerPolicy ¶
func (b *BaseAgreementWorker) MergeServicePolicyToConsumerPolicy(businessPol *policy.Policy, builtInSvcPol *externalpolicy.ExternalPolicy, servicePol *externalpolicy.ExternalPolicy, sId string) (*policy.Policy, *externalpolicy.ExternalPolicy, error)
This function merge the given business policy with the given built-in properties of the service and the given service policy from the top level service, if any. If the service policy is nil, then this function featches the service policy from the exchange and returned it back in order to let the policy manager to cache it.
func (*BaseAgreementWorker) VerifyUserInputForService ¶
func (b *BaseAgreementWorker) VerifyUserInputForService(svcName, svcOrg, svcVersion, svcArch string, default_input []policy.UserInput, userInput []policy.UserInput) error
Verfiy that all userInput variables are correctly typed and that non-defaulted userInput variables are specified. Returns nil if the
func (*BaseAgreementWorker) VerifyUserInputForServiceDef ¶
func (b *BaseAgreementWorker) VerifyUserInputForServiceDef(sdef *exchange.ServiceDefinition, svcOrg string, default_input []policy.UserInput, userInput []policy.UserInput) error
Verfiy that all userInput variables are correctly typed and that non-defaulted userInput variables are specified. Returns nil if the
type BaseConsumerProtocolHandler ¶
type BaseConsumerProtocolHandler struct {
// contains filtered or unexported fields
}
func (*BaseConsumerProtocolHandler) AlreadyReceivedReply ¶
func (c *BaseConsumerProtocolHandler) AlreadyReceivedReply(ag *persistence.Agreement) bool
func (*BaseConsumerProtocolHandler) CanSendMeterRecord ¶
func (c *BaseConsumerProtocolHandler) CanSendMeterRecord(ag *persistence.Agreement) bool
func (*BaseConsumerProtocolHandler) CancelAgreement ¶
func (b *BaseConsumerProtocolHandler) CancelAgreement(ag persistence.Agreement, reason string, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) DeferCommand ¶
func (b *BaseConsumerProtocolHandler) DeferCommand(cmd AgreementWork)
func (*BaseConsumerProtocolHandler) DeleteMessage ¶
func (b *BaseConsumerProtocolHandler) DeleteMessage(msgId int) error
func (*BaseConsumerProtocolHandler) DispatchProtocolMessage ¶
func (b *BaseConsumerProtocolHandler) DispatchProtocolMessage(cmd *NewProtocolMessageCommand, cph ConsumerProtocolHandler) error
func (*BaseConsumerProtocolHandler) GetCSSURL ¶
func (b *BaseConsumerProtocolHandler) GetCSSURL() string
func (*BaseConsumerProtocolHandler) GetDeferredCommands ¶
func (b *BaseConsumerProtocolHandler) GetDeferredCommands() []AgreementWork
func (*BaseConsumerProtocolHandler) GetDeviceMessageEndpoint ¶
func (*BaseConsumerProtocolHandler) GetExchangeId ¶
func (b *BaseConsumerProtocolHandler) GetExchangeId() string
func (*BaseConsumerProtocolHandler) GetExchangeToken ¶
func (b *BaseConsumerProtocolHandler) GetExchangeToken() string
func (*BaseConsumerProtocolHandler) GetExchangeURL ¶
func (b *BaseConsumerProtocolHandler) GetExchangeURL() string
func (*BaseConsumerProtocolHandler) GetHTTPFactory ¶
func (b *BaseConsumerProtocolHandler) GetHTTPFactory() *config.HTTPClientFactory
func (*BaseConsumerProtocolHandler) GetKnownBlockchain ¶
func (c *BaseConsumerProtocolHandler) GetKnownBlockchain(ag *persistence.Agreement) (string, string, string)
func (*BaseConsumerProtocolHandler) GetSendMessage ¶
func (b *BaseConsumerProtocolHandler) GetSendMessage() func(mt interface{}, pay []byte) error
func (*BaseConsumerProtocolHandler) GetServiceBased ¶
func (b *BaseConsumerProtocolHandler) GetServiceBased() bool
func (*BaseConsumerProtocolHandler) HandleAgreementTimeout ¶
func (b *BaseConsumerProtocolHandler) HandleAgreementTimeout(cmd *AgreementTimeoutCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleExtensionMessage ¶
func (b *BaseConsumerProtocolHandler) HandleExtensionMessage(cmd *NewProtocolMessageCommand) error
func (*BaseConsumerProtocolHandler) HandleMMSObjectPolicy ¶
func (b *BaseConsumerProtocolHandler) HandleMMSObjectPolicy(cmd *MMSObjectPolicyEventCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleMakeAgreement ¶
func (b *BaseConsumerProtocolHandler) HandleMakeAgreement(cmd *MakeAgreementCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandlePolicyChanged ¶
func (b *BaseConsumerProtocolHandler) HandlePolicyChanged(cmd *PolicyChangedCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandlePolicyDeleted ¶
func (b *BaseConsumerProtocolHandler) HandlePolicyDeleted(cmd *PolicyDeletedCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleServicePolicyChanged ¶
func (b *BaseConsumerProtocolHandler) HandleServicePolicyChanged(cmd *ServicePolicyChangedCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleServicePolicyDeleted ¶
func (b *BaseConsumerProtocolHandler) HandleServicePolicyDeleted(cmd *ServicePolicyDeletedCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleStopProtocol ¶
func (b *BaseConsumerProtocolHandler) HandleStopProtocol(cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) HandleWorkloadUpgrade ¶
func (b *BaseConsumerProtocolHandler) HandleWorkloadUpgrade(cmd *WorkloadUpgradeCommand, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) Name ¶
func (b *BaseConsumerProtocolHandler) Name() string
func (*BaseConsumerProtocolHandler) PersistBaseAgreement ¶
func (b *BaseConsumerProtocolHandler) PersistBaseAgreement(wi *InitiateAgreement, proposal abstractprotocol.Proposal, workerID string, hash string, sig string) error
func (*BaseConsumerProtocolHandler) PersistReply ¶
func (b *BaseConsumerProtocolHandler) PersistReply(reply abstractprotocol.ProposalReply, pol *policy.Policy, workerID string) error
func (*BaseConsumerProtocolHandler) RecordConsumerAgreementState ¶
func (*BaseConsumerProtocolHandler) SendEventMessage ¶
func (b *BaseConsumerProtocolHandler) SendEventMessage(event events.Message)
func (*BaseConsumerProtocolHandler) SetBlockchainClientAvailable ¶
func (c *BaseConsumerProtocolHandler) SetBlockchainClientAvailable(ev *events.BlockchainClientInitializedMessage)
func (*BaseConsumerProtocolHandler) SetBlockchainClientNotAvailable ¶
func (c *BaseConsumerProtocolHandler) SetBlockchainClientNotAvailable(ev *events.BlockchainClientStoppingMessage)
func (*BaseConsumerProtocolHandler) TerminateAgreement ¶
func (b *BaseConsumerProtocolHandler) TerminateAgreement(ag *persistence.Agreement, reason uint, mt interface{}, workerId string, cph ConsumerProtocolHandler)
func (*BaseConsumerProtocolHandler) UpdateProducer ¶
func (b *BaseConsumerProtocolHandler) UpdateProducer(ag *persistence.Agreement)
func (*BaseConsumerProtocolHandler) VerifyAgreement ¶
func (b *BaseConsumerProtocolHandler) VerifyAgreement(ag *persistence.Agreement, cph ConsumerProtocolHandler)
type BasicAgreementWorker ¶
type BasicAgreementWorker struct { *BaseAgreementWorker // contains filtered or unexported fields }
func NewBasicAgreementWorker ¶
func NewBasicAgreementWorker(c *BasicProtocolHandler, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, alm *AgreementLockManager, mmsObjMgr *MMSObjectPolicyManager) *BasicAgreementWorker
type BasicProtocolHandler ¶
type BasicProtocolHandler struct { *BaseConsumerProtocolHandler Work chan AgreementWork // outgoing commands for the workers // contains filtered or unexported fields }
func NewBasicProtocolHandler ¶
func NewBasicProtocolHandler(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, messages chan events.Message, mmsObjMgr *MMSObjectPolicyManager) *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) CanCancelNow ¶
func (c *BasicProtocolHandler) CanCancelNow(ag *persistence.Agreement) bool
func (*BasicProtocolHandler) CreateMeteringNotification ¶
func (c *BasicProtocolHandler) CreateMeteringNotification(mp policy.Meter, ag *persistence.Agreement) (*metering.MeteringNotification, error)
func (*BasicProtocolHandler) GetTerminationCode ¶
func (c *BasicProtocolHandler) GetTerminationCode(reason string) uint
func (*BasicProtocolHandler) GetTerminationReason ¶
func (c *BasicProtocolHandler) GetTerminationReason(code uint) string
func (*BasicProtocolHandler) HandleBlockchainEvent ¶
func (c *BasicProtocolHandler) HandleBlockchainEvent(cmd *BlockchainEventCommand)
func (*BasicProtocolHandler) HandleDeferredCommands ¶
func (c *BasicProtocolHandler) HandleDeferredCommands()
func (*BasicProtocolHandler) HandleExtensionMessage ¶
func (b *BasicProtocolHandler) HandleExtensionMessage(cmd *NewProtocolMessageCommand) error
func (*BasicProtocolHandler) Initialize ¶
func (c *BasicProtocolHandler) Initialize()
func (*BasicProtocolHandler) IsBlockchainWritable ¶
func (c *BasicProtocolHandler) IsBlockchainWritable(typeName string, name string, org string) bool
func (*BasicProtocolHandler) IsTerminationReasonNodeShutdown ¶
func (c *BasicProtocolHandler) IsTerminationReasonNodeShutdown(code uint) bool
func (*BasicProtocolHandler) PersistAgreement ¶
func (c *BasicProtocolHandler) PersistAgreement(wi *InitiateAgreement, proposal abstractprotocol.Proposal, workerID string) error
func (*BasicProtocolHandler) PersistReply ¶
func (c *BasicProtocolHandler) PersistReply(r abstractprotocol.ProposalReply, pol *policy.Policy, workerID string) error
func (*BasicProtocolHandler) PostReply ¶
func (b *BasicProtocolHandler) PostReply(agreementId string, proposal abstractprotocol.Proposal, reply abstractprotocol.ProposalReply, consumerPolicy *policy.Policy, org string, workerId string) error
func (*BasicProtocolHandler) SetBlockchainWritable ¶
func (c *BasicProtocolHandler) SetBlockchainWritable(ev *events.AccountFundedMessage)
func (*BasicProtocolHandler) String ¶
func (c *BasicProtocolHandler) String() string
func (*BasicProtocolHandler) TerminateAgreement ¶
func (c *BasicProtocolHandler) TerminateAgreement(ag *persistence.Agreement, reason uint, workerId string)
func (*BasicProtocolHandler) WorkQueue ¶
func (c *BasicProtocolHandler) WorkQueue() chan AgreementWork
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 BusinessPolicyEntry ¶
type BusinessPolicyEntry struct { Policy *policy.Policy `json:"policy,omitempty"` // the metadata for this business policy from the exchange, it is the converted to the internal policy format Updated uint64 `json:"updatedTime,omitempty"` // the time when this entry was updated Hash []byte `json:"hash,omitempty"` // a hash of the business policy to compare for matadata changes in the exchange ServicePolicies map[string]*ServicePolicyEntry `json:"servicePolicies,omitempty"` // map of the service id and service policies }
func NewBusinessPolicyEntry ¶
func NewBusinessPolicyEntry(pol *businesspolicy.BusinessPolicy, polId string) (*BusinessPolicyEntry, error)
Create a new BusinessPolicyEntry. It converts the businesspolicy to internal policy format. the business policy exchange id (or/id) is the header name for the internal generated policy.
func (*BusinessPolicyEntry) AddServicePolicy ¶
func (p *BusinessPolicyEntry) AddServicePolicy(svcPolicy *externalpolicy.ExternalPolicy, svcId string) (bool, error)
Add a service policy to a BusinessPolicyEntry returns true if there is an existing entry for svcId and it is updated with the new policy with is different. If the old and new service policies are same, it returns false.
func (*BusinessPolicyEntry) DeleteAllServicePolicies ¶
func (pe *BusinessPolicyEntry) DeleteAllServicePolicies(org string)
func (*BusinessPolicyEntry) RemoveServicePolicy ¶
func (p *BusinessPolicyEntry) RemoveServicePolicy(svcId string) bool
Remove a service policy from a BusinessPolicyEntry It returns true if the service policy exists and is removed
func (*BusinessPolicyEntry) ShortString ¶
func (p *BusinessPolicyEntry) ShortString() string
func (*BusinessPolicyEntry) String ¶
func (p *BusinessPolicyEntry) String() string
func (*BusinessPolicyEntry) UpdateEntry ¶
func (p *BusinessPolicyEntry) UpdateEntry(pol *businesspolicy.BusinessPolicy, polId string, newHash []byte) (*policy.Policy, error)
type BusinessPolicyManager ¶
type BusinessPolicyManager struct { ServedPolicies map[string]exchange.ServedBusinessPolicy // served node org, business policy org and business policy triplets. The key is the triplet exchange id. OrgPolicies map[string]map[string]*BusinessPolicyEntry // all served policies by this agbot. The first key is org, the second key is business policy exchange id without org. // contains filtered or unexported fields }
func NewBusinessPolicyManager ¶
func NewBusinessPolicyManager(eventChannel chan events.Message) *BusinessPolicyManager
func (*BusinessPolicyManager) AddMarshaledServicePolicy ¶
func (pm *BusinessPolicyManager) AddMarshaledServicePolicy(businessPolOrg, businessPolName, serviceId, servicePolString string) error
Add or update the given marshaled service policy.
func (*BusinessPolicyManager) AddServicePolicy ¶
func (pm *BusinessPolicyManager) AddServicePolicy(businessPolOrg string, businessPolName string, serviceId string, servicePol *externalpolicy.ExternalPolicy) error
Add or update the given service policy in all needed business policy entries. Send a message for each business policy if it is updating so that the event handler can reevaluating the agreements.
func (*BusinessPolicyManager) GetAllBusinessPolicyEntriesForOrg ¶
func (pm *BusinessPolicyManager) GetAllBusinessPolicyEntriesForOrg(org string) map[string]*BusinessPolicyEntry
func (*BusinessPolicyManager) GetAllPolicyOrgs ¶
func (pm *BusinessPolicyManager) GetAllPolicyOrgs() []string
func (*BusinessPolicyManager) GetBusinessPolicyEntry ¶
func (pm *BusinessPolicyManager) GetBusinessPolicyEntry(org string, pol *policy.Policy) *BusinessPolicyEntry
func (*BusinessPolicyManager) GetServedNodeOrgs ¶
func (pm *BusinessPolicyManager) GetServedNodeOrgs(polOrg string, polName string) []string
return an array of node orgs for the given served policy org and policy. this function is called from a different thread.
func (*BusinessPolicyManager) GetServicePoliciesForPolicy ¶
func (pm *BusinessPolicyManager) GetServicePoliciesForPolicy(org string, polName string) map[string]externalpolicy.ExternalPolicy
Return all cached service policies for a business policy
func (*BusinessPolicyManager) RemoveServicePolicy ¶
func (pm *BusinessPolicyManager) RemoveServicePolicy(businessPolOrg string, businessPolName string, serviceId string) error
Delete the given service policy in all the business policy entries. Send a message for each business policy so that the event handler can re-evaluating the agreements.
func (*BusinessPolicyManager) SetCurrentBusinessPolicies ¶
func (pm *BusinessPolicyManager) SetCurrentBusinessPolicies(servedPols map[string]exchange.ServedBusinessPolicy, polManager *policy.PolicyManager) error
Given a list of policy_org/policy/node_org triplets that this agbot is supposed to serve, save that list and convert it to map of maps (keyed by org and policy name) to hold all the policy meta data. This will allow the BusinessPolicyManager to know when the policy metadata changes.
func (*BusinessPolicyManager) ShortString ¶
func (pm *BusinessPolicyManager) ShortString() string
func (*BusinessPolicyManager) String ¶
func (pm *BusinessPolicyManager) String() string
func (*BusinessPolicyManager) UpdatePolicies ¶
func (pm *BusinessPolicyManager) UpdatePolicies(org string, definedPolicies map[string]exchange.ExchangeBusinessPolicy, polManager *policy.PolicyManager) error
For each org that the agbot is supporting, take the set of business policies defined within the org and save them into the BusinessPolicyManager. When new or updated policies are discovered, clear ServicePolicies for that BusinessPolicyEntry so that new businees polices can be filled later.
type CacheServicePolicyCommand ¶
type CacheServicePolicyCommand struct {
Msg events.CacheServicePolicyMessage
}
==============================================================================================================
func NewCacheServicePolicyCommand ¶
func NewCacheServicePolicyCommand(msg *events.CacheServicePolicyMessage) *CacheServicePolicyCommand
func (CacheServicePolicyCommand) ShortString ¶
func (e CacheServicePolicyCommand) ShortString() string
type CancelAgreement ¶
type CancelAgreement struct { AgreementId string Protocol string Reason uint MessageId int // contains filtered or unexported fields }
func (CancelAgreement) Type ¶
func (c CancelAgreement) Type() string
type ClientInitializedCommand ¶
type ClientInitializedCommand struct {
Msg events.BlockchainClientInitializedMessage
}
==============================================================================================================
func NewClientInitializedCommand ¶
func NewClientInitializedCommand(msg *events.BlockchainClientInitializedMessage) *ClientInitializedCommand
func (ClientInitializedCommand) ShortString ¶
func (e ClientInitializedCommand) ShortString() string
type ClientStoppingCommand ¶
type ClientStoppingCommand struct {
Msg events.BlockchainClientStoppingMessage
}
==============================================================================================================
func NewClientStoppingCommand ¶
func NewClientStoppingCommand(msg *events.BlockchainClientStoppingMessage) *ClientStoppingCommand
func (ClientStoppingCommand) ShortString ¶
func (e ClientStoppingCommand) ShortString() string
type ConsumerProtocolHandler ¶
type ConsumerProtocolHandler interface { Initialize() Name() string AcceptCommand(cmd worker.Command) bool AgreementProtocolHandler(typeName string, name string, org string) abstractprotocol.ProtocolHandler WorkQueue() chan AgreementWork DispatchProtocolMessage(cmd *NewProtocolMessageCommand, cph ConsumerProtocolHandler) error PersistAgreement(wi *InitiateAgreement, proposal abstractprotocol.Proposal, workerID string) error PersistReply(reply abstractprotocol.ProposalReply, pol *policy.Policy, workerID string) error HandleAgreementTimeout(cmd *AgreementTimeoutCommand, cph ConsumerProtocolHandler) HandleBlockchainEvent(cmd *BlockchainEventCommand) HandlePolicyChanged(cmd *PolicyChangedCommand, cph ConsumerProtocolHandler) HandlePolicyDeleted(cmd *PolicyDeletedCommand, cph ConsumerProtocolHandler) HandleServicePolicyChanged(cmd *ServicePolicyChangedCommand, cph ConsumerProtocolHandler) HandleServicePolicyDeleted(cmd *ServicePolicyDeletedCommand, cph ConsumerProtocolHandler) HandleMMSObjectPolicy(cmd *MMSObjectPolicyEventCommand, cph ConsumerProtocolHandler) HandleWorkloadUpgrade(cmd *WorkloadUpgradeCommand, cph ConsumerProtocolHandler) HandleMakeAgreement(cmd *MakeAgreementCommand, cph ConsumerProtocolHandler) HandleStopProtocol(cph ConsumerProtocolHandler) GetTerminationCode(reason string) uint GetTerminationReason(code uint) string IsTerminationReasonNodeShutdown(code uint) bool GetSendMessage() func(mt interface{}, pay []byte) error RecordConsumerAgreementState(agreementId string, pol *policy.Policy, org string, state string, workerID string) error DeleteMessage(msgId int) error CreateMeteringNotification(mp policy.Meter, agreement *persistence.Agreement) (*metering.MeteringNotification, error) TerminateAgreement(agreement *persistence.Agreement, reason uint, workerId string) VerifyAgreement(ag *persistence.Agreement, cph ConsumerProtocolHandler) GetDeviceMessageEndpoint(deviceId string, workerId string) (string, []byte, error) SetBlockchainClientAvailable(ev *events.BlockchainClientInitializedMessage) SetBlockchainClientNotAvailable(ev *events.BlockchainClientStoppingMessage) SetBlockchainWritable(ev *events.AccountFundedMessage) IsBlockchainWritable(typeName string, name string, org string) bool CanCancelNow(agreement *persistence.Agreement) bool DeferCommand(cmd AgreementWork) HandleDeferredCommands() PostReply(agreementId string, proposal abstractprotocol.Proposal, reply abstractprotocol.ProposalReply, consumerPolicy *policy.Policy, org string, workerId string) error UpdateProducer(ag *persistence.Agreement) HandleExtensionMessage(cmd *NewProtocolMessageCommand) error AlreadyReceivedReply(ag *persistence.Agreement) bool GetKnownBlockchain(ag *persistence.Agreement) (string, string, string) CanSendMeterRecord(ag *persistence.Agreement) bool GetExchangeId() string GetExchangeToken() string GetExchangeURL() string GetCSSURL() string GetServiceBased() bool GetHTTPFactory() *config.HTTPClientFactory SendEventMessage(event events.Message) }
func CreateConsumerPH ¶
func CreateConsumerPH(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, msgq chan events.Message, mmsObjMgr *MMSObjectPolicyManager) ConsumerProtocolHandler
type DVState ¶
type DVState struct {
// contains filtered or unexported fields
}
Agreement governance timing state. Used in the GovernAgreements subworker.
type DeviceEntry ¶
type DeviceEntry struct { Id string `json:"id"` Lat float64 `json:"lat"` Lon float64 `json:"lon"` Agreements []AgreementEntry `json:"contracts"` }
type HandleDataReceivedAck ¶
type HandleDataReceivedAck struct { Ack string From string // deprecated whisper address SenderId string // exchange Id of sender SenderPubKey []byte MessageId int // contains filtered or unexported fields }
func (HandleDataReceivedAck) String ¶
func (c HandleDataReceivedAck) String() string
func (HandleDataReceivedAck) Type ¶
func (c HandleDataReceivedAck) Type() string
type HandleReply ¶
type HandleReply struct { Reply abstractprotocol.ProposalReply From string // deprecated whisper address SenderId string // exchange Id of sender SenderPubKey []byte MessageId int // contains filtered or unexported fields }
func (HandleReply) String ¶
func (c HandleReply) String() string
func (HandleReply) Type ¶
func (c HandleReply) Type() string
type HandleWorkloadUpgrade ¶
type HandleWorkloadUpgrade struct { AgreementId string Protocol string Device string PolicyName string // contains filtered or unexported fields }
func (HandleWorkloadUpgrade) Type ¶
func (c HandleWorkloadUpgrade) Type() string
type HorizonAgbot ¶
========================================================================================== Utility functions used by many of the API endpoints.
func NewHorizonAgbot ¶
func NewHorizonAgbot(id string, org string) *HorizonAgbot
type HorizonAgbotConfig ¶
type InitiateAgreement ¶
type InitiateAgreement struct { ProducerPolicy policy.Policy // the producer policy received from the exchange - demarshalled OriginalProducerPolicy string // the producer policy received from the exchange - original in string form to be sent back ConsumerPolicy policy.Policy // the consumer policy we're matched up with - this is a copy so that we can modify/augment it Org string // the org from which the consumer policy originated Device exchange.SearchResultDevice // the device entry in the exchange ConsumerPolicyName string // the name of the consumer policy in the exchange ServicePolicies map[string]externalpolicy.ExternalPolicy // cached service polices, keyed by service id. it is a subset of the service versions in the consumer policy file // contains filtered or unexported fields }
func (InitiateAgreement) String ¶
func (c InitiateAgreement) String() string
func (InitiateAgreement) Type ¶
func (c InitiateAgreement) Type() string
type MMSObjectPolicyEntry ¶
type MMSObjectPolicyEntry struct { Policy exchange.ObjectDestinationPolicy `json:"policy,omitempty"` // the metadata for this object policy in the MMS ServiceID common.ServiceID `json:"service,omitempty"` // the service id for which we created this entry VersionExpression *semanticversion.Version_Expression `json:"version,omitempty"` // the service version expression Updated uint64 `json:"updatedTime,omitempty"` // the time when this entry was updated }
func (*MMSObjectPolicyEntry) ShortString ¶
func (p *MMSObjectPolicyEntry) ShortString() string
func (*MMSObjectPolicyEntry) String ¶
func (p *MMSObjectPolicyEntry) String() string
func (*MMSObjectPolicyEntry) UpdateEntry ¶
func (p *MMSObjectPolicyEntry) UpdateEntry(pol *exchange.ObjectDestinationPolicy, serviceID common.ServiceID, ve *semanticversion.Version_Expression) (*MMSObjectPolicyEntry, error)
type MMSObjectPolicyEventCommand ¶
type MMSObjectPolicyEventCommand struct {
Msg events.MMSObjectPolicyMessage
}
==============================================================================================================
func NewMMSObjectPolicyEventCommand ¶
func NewMMSObjectPolicyEventCommand(msg *events.MMSObjectPolicyMessage) *MMSObjectPolicyEventCommand
func (MMSObjectPolicyEventCommand) ShortString ¶
func (e MMSObjectPolicyEventCommand) ShortString() string
type MMSObjectPolicyManager ¶
type MMSObjectPolicyManager struct { ServedOrgs map[string]exchange.ServedBusinessPolicy // The served node org, business policy org and business policy triplets. The key is the triplet exchange id. // contains filtered or unexported fields }
This is the main object that manages the cache of object policies. It uses the agbot's served business policies configuration to figure out which orgs it is going to serve objects from.
func NewMMSObjectPolicyManager ¶
func NewMMSObjectPolicyManager(cfg *config.HorizonConfig) *MMSObjectPolicyManager
func (*MMSObjectPolicyManager) GetAllPolicyOrgs ¶
func (m *MMSObjectPolicyManager) GetAllPolicyOrgs() []string
func (*MMSObjectPolicyManager) GetObjectPolicies ¶
func (m *MMSObjectPolicyManager) GetObjectPolicies(org string, serviceName string, arch string, version string) *exchange.ObjectDestinationPolicies
Retrieve the object policy from the map of policies. The input serviceName is assumed to be org qualified.
func (*MMSObjectPolicyManager) NewMMSObjectPolicyEntry ¶
func (m *MMSObjectPolicyManager) NewMMSObjectPolicyEntry(pol *exchange.ObjectDestinationPolicy, serviceID common.ServiceID, ve *semanticversion.Version_Expression) *MMSObjectPolicyEntry
Create a new MMSObjectPolicyEntry. It converts the businesspolicy to internal policy format. the business policy exchange id (or/id) is the header name for the internal generated policy.
func (*MMSObjectPolicyManager) SetCurrentPolicyOrgs ¶
func (m *MMSObjectPolicyManager) SetCurrentPolicyOrgs(servedPols map[string]exchange.ServedBusinessPolicy) error
Given a list of policy_org/policy/node_org triplets that this agbot is supposed to serve, save that list and convert it to map of maps (keyed by org and service name) to hold all the policy meta data. This will allow the MMSObjectPolicyManager to know when the policy metadata changes.
func (*MMSObjectPolicyManager) String ¶
func (m *MMSObjectPolicyManager) String() string
func (*MMSObjectPolicyManager) UpdatePolicies ¶
func (m *MMSObjectPolicyManager) UpdatePolicies(org string, updatedPolicies *exchange.ObjectDestinationPolicies, objQueryHandler exchange.ObjectQueryHandler) ([]events.Message, error)
This function gets called when object policy updates are detected by the agbot. It will be common for no updates to be received most of the time. It should be invoked on a regular basis.
type MakeAgreementCommand ¶
type MakeAgreementCommand struct { ProducerPolicy policy.Policy // the producer policy received from the exchange ConsumerPolicy policy.Policy // the consumer policy we're matched up with Org string // the org of the consumer ConsumerPolicyName string // the name of the consumer policy in the exchange Device exchange.SearchResultDevice // the device entry in the exchange ServicePolicies map[string]externalpolicy.ExternalPolicy // cached service polices, keyed by service id. it is a subset of the service versions in the consumer policy file }
==============================================================================================================
func NewMakeAgreementCommand ¶
func NewMakeAgreementCommand(pPol policy.Policy, cPol policy.Policy, org string, polname string, dev exchange.SearchResultDevice, cachedServicePolicies map[string]externalpolicy.ExternalPolicy) *MakeAgreementCommand
func (MakeAgreementCommand) ShortString ¶
func (e MakeAgreementCommand) ShortString() string
type NHPatternEntry ¶
type NHPatternEntry struct { Nodes *exchange.NodeHealthStatus // The node info from the exchange Updated bool // Indicates whether or not the node info has been updated from the exchange. This field is set to false after governance iterates all agreements. LastCallTime string // The last time the exchange was called to obtain status }
func NewNHPatternEntry ¶
func NewNHPatternEntry() *NHPatternEntry
func (*NHPatternEntry) String ¶
func (n *NHPatternEntry) String() string
type NewProtocolMessageCommand ¶
==============================================================================================================
func NewNewProtocolMessageCommand ¶
func NewNewProtocolMessageCommand(msg []byte, msgId int, deviceId string, pubkey []byte) *NewProtocolMessageCommand
func (NewProtocolMessageCommand) ShortString ¶
func (p NewProtocolMessageCommand) ShortString() string
type NodeHealthHandler ¶
type NodeHealthManager ¶
type NodeHealthManager struct { Patterns map[string]*NHPatternEntry // A map of patterns for which this agbot has agreements NodeOrgs map[string][]string // a map of node orgs for each pattern used by current active agreements }
func NewNodeHealthManager ¶
func NewNodeHealthManager() *NodeHealthManager
func (*NodeHealthManager) AgreementOutOfPolicy ¶
func (m *NodeHealthManager) AgreementOutOfPolicy(pattern string, org string, deviceId string, agreementId string, start uint64, interval int) bool
Determine if the input agreement id is still present in the exchange. Return false (not out of policy) if the agreement is present. If the agreement is not present then give the node NHCheckAgreementStatus + agbot finalized time to get the agreement object into the exchange.
func (*NodeHealthManager) NodeOutOfPolicy ¶
func (m *NodeHealthManager) NodeOutOfPolicy(pattern string, org string, deviceId string, interval int) bool
Determine if the input node's heartbeat is overdue, i.e. beyond the policy interval. Return false (not out of policy) if the agrement is still present.
func (*NodeHealthManager) ResetUpdateStatus ¶
func (m *NodeHealthManager) ResetUpdateStatus()
Clear the Updated flag in each pattern entry so that future requests for status will first go the exchange to get any updates.
func (*NodeHealthManager) SetNodeOrgs ¶
func (m *NodeHealthManager) SetNodeOrgs(agreements []persistence.Agreement, agreementProtocol string)
set the node orgs for patterns for current active agreements under the given agreement protocol
func (*NodeHealthManager) SetUpdatedStatus ¶
func (m *NodeHealthManager) SetUpdatedStatus(pattern string, org string, nhHandler NodeHealthHandler) error
Make sure the manager has the latest status info from the exchange.
func (*NodeHealthManager) String ¶
func (n *NodeHealthManager) String() string
type ObjectPolicyChange ¶
type ObjectPolicyChange struct { Event events.MMSObjectPolicyMessage // contains filtered or unexported fields }
func (ObjectPolicyChange) Type ¶
func (c ObjectPolicyChange) Type() string
type PatternEntry ¶
type PatternEntry struct { Pattern *exchange.Pattern `json:"pattern,omitempty"` // the metadata for this pattern from the exchange Updated uint64 `json:"updatedTime,omitempty"` // the time when this entry was updated Hash []byte `json:"hash,omitempty"` // a hash of the current entry to compare for matadata changes in the exchange PolicyFileNames []string `json:"policyFileNames,omitempty"` // the list of policy names generated for this pattern }
func NewPatternEntry ¶
func NewPatternEntry(p *exchange.Pattern) (*PatternEntry, error)
func (*PatternEntry) AddPolicyFileName ¶
func (pe *PatternEntry) AddPolicyFileName(fileName string)
func (*PatternEntry) DeleteAllPolicyFiles ¶
func (pe *PatternEntry) DeleteAllPolicyFiles(policyPath string, org string) error
func (*PatternEntry) ShortString ¶
func (p *PatternEntry) ShortString() string
func (*PatternEntry) String ¶
func (p *PatternEntry) String() string
func (*PatternEntry) UpdateEntry ¶
func (pe *PatternEntry) UpdateEntry(pattern *exchange.Pattern, newHash []byte)
type PatternManager ¶
type PatternManager struct { ServedPatterns map[string]exchange.ServedPattern // served node org, pattern org and pattern triplets OrgPatterns map[string]map[string]*PatternEntry // all served paterns by this agbot // contains filtered or unexported fields }
func NewPatternManager ¶
func NewPatternManager() *PatternManager
func (*PatternManager) GetServedNodeOrgs ¶
func (pm *PatternManager) GetServedNodeOrgs(pattten_org string, pattern string) []string
return an array of node orgs for the given served pattern org and pattern. this function is called from a different thread.
func (*PatternManager) SetCurrentPatterns ¶
func (pm *PatternManager) SetCurrentPatterns(servedPatterns map[string]exchange.ServedPattern, policyPath string) error
Given a list of pattern_org/pattern/node_org triplets that this agbot is supposed to serve, save that list and convert it to map of maps (keyed by org and pattern name) to hold all the pattern meta data. This will allow the PatternManager to know when the pattern metadata changes.
func (*PatternManager) ShortString ¶
func (p *PatternManager) ShortString() string
func (*PatternManager) String ¶
func (pm *PatternManager) String() string
func (*PatternManager) UpdatePatternPolicies ¶
func (pm *PatternManager) UpdatePatternPolicies(org string, definedPatterns map[string]exchange.Pattern, policyPath string) error
For each org that the agbot is supporting, take the set of patterns defined within the org and save them into the PatternManager. When new or updated patterns are discovered, generate policy files for each pattern so that the agbot can start serving the workloads and services.
type PolicyChangedCommand ¶
type PolicyChangedCommand struct {
Msg events.PolicyChangedMessage
}
==============================================================================================================
func NewPolicyChangedCommand ¶
func NewPolicyChangedCommand(msg events.PolicyChangedMessage) *PolicyChangedCommand
func (PolicyChangedCommand) ShortString ¶
func (p PolicyChangedCommand) ShortString() string
type PolicyDeletedCommand ¶
type PolicyDeletedCommand struct {
Msg events.PolicyDeletedMessage
}
==============================================================================================================
func NewPolicyDeletedCommand ¶
func NewPolicyDeletedCommand(msg events.PolicyDeletedMessage) *PolicyDeletedCommand
func (PolicyDeletedCommand) ShortString ¶
func (p PolicyDeletedCommand) ShortString() string
type ServicePolicyChangedCommand ¶
type ServicePolicyChangedCommand struct {
Msg events.ServicePolicyChangedMessage
}
==============================================================================================================
func NewServicePolicyChangedCommand ¶
func NewServicePolicyChangedCommand(msg *events.ServicePolicyChangedMessage) *ServicePolicyChangedCommand
func (ServicePolicyChangedCommand) ShortString ¶
func (e ServicePolicyChangedCommand) ShortString() string
type ServicePolicyDeletedCommand ¶
type ServicePolicyDeletedCommand struct {
Msg events.ServicePolicyDeletedMessage
}
==============================================================================================================
func NewServicePolicyDeletedCommand ¶
func NewServicePolicyDeletedCommand(msg *events.ServicePolicyDeletedMessage) *ServicePolicyDeletedCommand
func (ServicePolicyDeletedCommand) ShortString ¶
func (e ServicePolicyDeletedCommand) ShortString() string
type ServicePolicyEntry ¶
type ServicePolicyEntry struct { Policy *externalpolicy.ExternalPolicy `json:"policy,omitempty"` // the metadata for this service policy from the exchange. Updated uint64 `json:"updatedTime,omitempty"` // the time when this entry was updated Hash []byte `json:"hash,omitempty"` // a hash of the service policy to compare for matadata changes in the exchange }
func NewServicePolicyEntry ¶
func NewServicePolicyEntry(p *externalpolicy.ExternalPolicy, svcId string) (*ServicePolicyEntry, error)
func (*ServicePolicyEntry) ShortString ¶
func (p *ServicePolicyEntry) ShortString() string
func (*ServicePolicyEntry) String ¶
func (p *ServicePolicyEntry) String() string
type StopWorker ¶
type StopWorker struct {
// contains filtered or unexported fields
}
func (StopWorker) String ¶
func (c StopWorker) String() string
func (StopWorker) Type ¶
func (c StopWorker) Type() string
type UpgradeDevice ¶
type UpgradeDevice struct { Device string `json:"device"` AgreementId string `json:"agreementId"` Org string `json:"org"` }
func (*UpgradeDevice) IsValid ¶
func (b *UpgradeDevice) IsValid() (bool, string)
type WorkloadUpgradeCommand ¶
type WorkloadUpgradeCommand struct {
Msg events.ABApiWorkloadUpgradeMessage
}
==============================================================================================================
func NewWorkloadUpgradeCommand ¶
func NewWorkloadUpgradeCommand(msg events.ABApiWorkloadUpgradeMessage) *WorkloadUpgradeCommand
func (WorkloadUpgradeCommand) ShortString ¶
func (e WorkloadUpgradeCommand) ShortString() string
type WorkloadUsagesByDeviceId ¶
type WorkloadUsagesByDeviceId []persistence.WorkloadUsage
Helper functions for sorting workload usages
func (WorkloadUsagesByDeviceId) Len ¶
func (s WorkloadUsagesByDeviceId) Len() int
func (WorkloadUsagesByDeviceId) Less ¶
func (s WorkloadUsagesByDeviceId) Less(i, j int) bool
func (WorkloadUsagesByDeviceId) Swap ¶
func (s WorkloadUsagesByDeviceId) Swap(i, j int)