{"modulePath":"github.com/contiv/vpp","version":"v3.3.3+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Functions\n\n```go\nfunc DeleteAll(txn UpdateOperations, values KeyValuePairs)\n```\nDeleteAll is a helper function to prepare Delete for multiple key-value pairs into a single transaction.\n\n```go\nfunc NewAbortEventError(origErr error) error\n```\nNewAbortEventError is the constructor for the AbortEventError.\n\n```go\nfunc NewFatalError(origErr error) error\n```\nNewFatalError is the constructor for FatalError.\n\n```go\nfunc PutAll(txn ResyncOperations, values KeyValuePairs)\n```\nPutAll is a helper function to prepare Put for multiple key-value pairs into a single transaction.\n\n## Types\n\n```go\ntype AbortEventError struct {\n\t// contains filtered or unexported fields\n}\n```\nAbortEventError tells controller to abort the processing of the event (and for Update/RevertOnFailure to revert the changes). The agent does not have to restart but resync should be performed as soon as possible.\n\n```go\nfunc (e *AbortEventError) Error() string\n```\nError delegates the call to the underlying error.\n\n```go\nfunc (e *AbortEventError) GetOriginalError() error\n```\nGetOriginalError returns the underlying error.\n\n```go\ntype ConfigRetriever interface {\n\t// GetConfig returns value for the given key in the controller's transaction. If data for\n\t// the key is not part of the transaction stored value from internal config is returned.\n\tGetConfig(key string) proto.Message\n}\n```\nConfigRetriever allows to read configuration in order to adjust a config item by multiple event handlers.\n\n```go\ntype DBResync struct {\n\tLocal          bool // against local DB?\n\tKubeState      KubeStateData\n\tExternalConfig KeyValuePairs\n}\n```\nDBResync is a Resync Event that carries snapshot of the database for all watched Kubernetes resources and the external configuration (for vpp-agent).\n\n```go\nfunc NewDBResync() *DBResync\n```\nNewDBResync is a constructor for DBResync\n\n```go\nfunc (ev *DBResync) Done(error)\n```\nDone is NOOP.\n\n```go\nfunc (ev *DBResync) GetName() string\n```\nGetName returns name of the DBResync event.\n\n```go\nfunc (ev *DBResync) IsBlocking() bool\n```\nIsBlocking returns false.\n\n```go\nfunc (ev *DBResync) Method() EventMethodType\n```\nMethod is FullResync.\n\n```go\nfunc (ev *DBResync) String() string\n```\nString describes DBResync event.\n\n```go\ntype Event interface {\n\t// GetName should return a string identifier, unique among the event types,\n\t// but also somewhat descriptive for humans.\n\tGetName() string\n\n\t// String should return a description of the event.\n\tString() string\n\n\t// Method tells whether the event can be reacted to by an incremental change\n\t// (Update) or if a full re-synchronization is needed (Resync, i.e. complex\n\t// change).\n\tMethod() EventMethodType\n\n\t// IsBlocking should return true if any producer of this event ever waits\n\t// for the event result (sent using the method Done()).\n\tIsBlocking() bool\n\n\t// Done is used to mark the event as processed.\n\t// A specific Event implementation may use this method for example to deliver\n\t// the return value back to the send of the event.\n\tDone(error)\n}\n```\nEvent represents something that has happened and may cause some reaction.\n\n```go\ntype EventHandler interface {\n\t// String identifies the handler for the Controller and in the logs.\n\t// Note: Plugins already implement Stringer.\n\tString() string\n\n\t// HandlesEvent is used by Controller to check if the event is being handled\n\t// by this handler.\n\tHandlesEvent(event Event) bool\n\n\t// Resync is called by Controller to handle event that requires full\n\t// re-synchronization.\n\t// For startup resync, resyncCount is 1. Higher counter values identify\n\t// run-time resync.\n\tResync(event Event, kubeStateData KubeStateData, resyncCount int, txn ResyncOperations) error\n\n\t// Update is called by Controller to handle event that can be reacted to by\n\t// an incremental change.\n\t// \u003cchangeDescription\u003e should be human-readable description of changes that\n\t// have to be performed (via txn or internally) - can be empty.\n\tUpdate(event Event, txn UpdateOperations) (changeDescription string, err error)\n\n\t// Revert is called to revert already executed internal changes (in the plugin\n\t// itself, not in VPP/Linux network stack) for a RevertOnFailure event that\n\t// has failed in the processing.\n\tRevert(event Event) error\n}\n```\nEventHandler declares methods that event handler must implement.\n\n```go\ntype EventLoop interface {\n\t// PushEvent adds the given event into the queue for processing.\n\tPushEvent(event Event) error\n}\n```\nEventLoop defines method for accessing the main event loop.\n\n```go\ntype EventMethodType int\n```\nEventMethodType is either Resync or Update.\n\n```go\nconst (\n\t// FullResync event requires to be reacted to by a full re-synchronization\n\t// (Contiv -\u003e VPP-agent \u003c-\u003e SB).\n\tFullResync EventMethodType = iota\n\n\t// DownstreamResync triggers re-synchronization between vpp-agent and SB.\n\t// Event is fully processed by the Controller (not passed to event handlers).\n\tDownstreamResync\n\n\t// UpstreamResync triggers re-synchronization between Contiv and VPP-agent.\n\t// It can be used whenever it is far easier to re-build the configuration\n\t// from the scratch as opposed to calculating an incremental change.\n\tUpstreamResync\n\n\t// Update event can be reacted to by an incremental change.\n\tUpdate\n)\n```\n\n```go\ntype ExternalConfigChange struct {\n\tSource     string\n\tUpdatedKVs KeyValuePairs\n\t// contains filtered or unexported fields\n}\n```\nExternalConfigChange is an Update event that represents change for one or more keys from the external configuration (for vpp-agent).\n\n```go\nfunc NewExternalConfigChange(source string, blocking bool) *ExternalConfigChange\n```\nNewExternalConfigChange is a constructor for ExternalConfigChange.\n\n```go\nfunc (ev *ExternalConfigChange) Direction() UpdateDirectionType\n```\nDirection is Forward.\n\n```go\nfunc (ev *ExternalConfigChange) Done(err error)\n```\nDone propagates error to the event producer.\n\n```go\nfunc (ev *ExternalConfigChange) GetName() string\n```\nGetName returns name of the ExternalConfigChange event.\n\n```go\nfunc (ev *ExternalConfigChange) IsBlocking() bool\n```\nIsBlocking returns what is configured in the constructor.\n\n```go\nfunc (ev *ExternalConfigChange) Method() EventMethodType\n```\nMethod is Update.\n\n```go\nfunc (ev *ExternalConfigChange) String() string\n```\nString describes ExternalConfigChange event.\n\n```go\nfunc (ev *ExternalConfigChange) TransactionType() UpdateTransactionType\n```\nTransactionType is BestEffort.\n\n```go\nfunc (ev *ExternalConfigChange) Wait() error\n```\nWait waits for the result of the ExternalConfigChange event.\n\n```go\ntype ExternalConfigResync struct {\n\tSource         string\n\tExternalConfig KeyValuePairs\n\t// contains filtered or unexported fields\n}\n```\nExternalConfigResync is a Resync event triggered by external config source. Note: External config from Remote DB uses DBResync instead.\n\n```go\nfunc NewExternalConfigResync(source string, blocking bool) *ExternalConfigResync\n```\nNewExternalConfigResync is a constructor for ExternalConfigResync.\n\n```go\nfunc (ev *ExternalConfigResync) Done(err error)\n```\nDone propagates error to the event producer.\n\n```go\nfunc (ev *ExternalConfigResync) GetName() string\n```\nGetName returns name of the ExternalConfigResync event.\n\n```go\nfunc (ev *ExternalConfigResync) IsBlocking() bool\n```\nIsBlocking returns what is configured in the constructor.\n\n```go\nfunc (ev *ExternalConfigResync) Method() EventMethodType\n```\nMethod is Update.\n\n```go\nfunc (ev *ExternalConfigResync) String() string\n```\nString describes ExternalConfigResync event.\n\n```go\nfunc (ev *ExternalConfigResync) Wait() error\n```\nWait waits for the result of the ExternalConfigResync event.\n\n```go\ntype FatalError struct {\n\t// contains filtered or unexported fields\n}\n```\nFatalError tells Controller to abort the event loop and stop the agent as soon as possible.\n\n```go\nfunc (e *FatalError) Error() string\n```\nError delegates the call to the underlying error.\n\n```go\nfunc (e *FatalError) GetOriginalError() error\n```\nGetOriginalError returns the underlying error.\n\n```go\ntype HealingResync struct {\n\tType  HealingResyncType\n\tError error // non-nil if the resync is of type AfterError\n}\n```\nHealingResync is supposed to \"heal\" the contiv-vswitch. It is run either after an error occurred or periodically.\n\n```go\nfunc (ev *HealingResync) Done(error)\n```\nDone is NOOP.\n\n```go\nfunc (ev *HealingResync) GetName() string\n```\nGetName returns name of the HealingResync event.\n\n```go\nfunc (ev *HealingResync) IsBlocking() bool\n```\nIsBlocking returns false.\n\n```go\nfunc (ev *HealingResync) Method() EventMethodType\n```\nMethod is DownstreamResync for periodic healing, otherwise FullResync is used to heal after an error.\n\n```go\nfunc (ev *HealingResync) String() string\n```\nString describes HealingResync event.\n\n```go\ntype HealingResyncType int\n```\nHealingResyncType is either Periodic or AfterError.\n\n```go\nconst (\n\t// Periodic healing resync, when enabled in the configuration, is run periodically\n\t// to trigger the Downstream resync (sync between vpp-agent and VPP/Linux).\n\tPeriodic HealingResyncType = iota\n\n\t// AfterError healing resync is triggered after an event processing ended with error.\n\tAfterError\n)\n```\n\n```go\ntype KeyValuePairs map[string]proto.Message\n```\nKeyValuePairs is a set of key-value pairs.\n\n```go\ntype KubeStateChange struct {\n\tKey       string\n\tResource  string\n\tPrevValue proto.Message // nil if newly added\n\tNewValue  proto.Message // nil if deleted\n}\n```\nKubeStateChange is an Update event that represents change for one key from Kubernetes state data.\n\n```go\nfunc (ev *KubeStateChange) Direction() UpdateDirectionType\n```\nDirection is forward.\n\n```go\nfunc (ev *KubeStateChange) Done(error)\n```\nDone is NOOP.\n\n```go\nfunc (ev *KubeStateChange) GetName() string\n```\nGetName returns name of the KubeStateChange event.\n\n```go\nfunc (ev *KubeStateChange) IsBlocking() bool\n```\nIsBlocking returns false.\n\n```go\nfunc (ev *KubeStateChange) Method() EventMethodType\n```\nMethod is Update.\n\n```go\nfunc (ev *KubeStateChange) String() string\n```\nString describes KubeStateChange event.\n\n```go\nfunc (ev *KubeStateChange) TransactionType() UpdateTransactionType\n```\nTransactionType is BestEffort.\n\n```go\ntype KubeStateData map[string]KeyValuePairs // resource name -\u003e {(key, value)}\n\n```\nKubeStateData contains Kubernetes state data organized as key-value pairs sorted by the resource type.\n\n```go\nfunc NewKubeStateData() KubeStateData\n```\nNewKubeStateData is a constructor for KubeStateData.\n\n```go\ntype ResyncOperations interface {\n\t// Put add request to the transaction to add or modify a value.\n\t// \u003cvalue\u003e cannot be nil.\n\tPut(key string, value proto.Message)\n\n\t// Get is used to obtain value already prepared to be applied by this transaction.\n\t// Until the transaction is committed, provided values can still be changed.\n\t// Returns nil if the value is set to be deleted, or has not been set at all.\n\tGet(key string) proto.Message\n}\n```\nResyncOperations lists operations needed to build transaction for Resync-type events.\n\n```go\ntype Shutdown struct {\n\t// contains filtered or unexported fields\n}\n```\nShutdown event is triggered when the agent is being closed.\n\n```go\nfunc NewShutdownEvent() *Shutdown\n```\nNewShutdownEvent is constructor for Shutdown event.\n\n```go\nfunc (ev *Shutdown) Direction() UpdateDirectionType\n```\nDirection is forward.\n\n```go\nfunc (ev *Shutdown) Done(err error)\n```\nDone propagates result to the event producer.\n\n```go\nfunc (ev *Shutdown) GetName() string\n```\nGetName returns name of the Shutdown event.\n\n```go\nfunc (ev *Shutdown) IsBlocking() bool\n```\nIsBlocking returns true.\n\n```go\nfunc (ev *Shutdown) Method() EventMethodType\n```\nMethod is Update.\n\n```go\nfunc (ev *Shutdown) String() string\n```\nString describes Shutdown event.\n\n```go\nfunc (ev *Shutdown) TransactionType() UpdateTransactionType\n```\nTransactionType is BestEffort.\n\n```go\nfunc (ev *Shutdown) Wait() error\n```\nWait waits for the result of the shutdown event.\n\n```go\ntype Transaction interface {\n\tUpdateOperations\n\n\t// Commit applies the requested transaction changes.\n\tCommit(ctx context.Context) (seqNum uint64, err error)\n}\n```\nTransaction defines operations needed to build and commit a transaction.\n\n```go\ntype UpdateDirectionType int\n```\nUpdateDirectionType is either Forward or Reverse.\n\n```go\nconst (\n\t// Forward event is processed by handlers in the exact same order as passed\n\t// to the Controller - ensuring for every handler that its dependencies\n\t// have already reacted to the event.\n\tForward UpdateDirectionType = iota\n\n\t// Reverse event is processed by handlers in the backward order, ensuring\n\t// for every handler that its dependencies are still in the pre-event state.\n\tReverse\n)\n```\n\n```go\ntype UpdateEvent interface {\n\t// TransactionType defines how to treat already executed changes of a failed\n\t// event processing - whether to keep them (and be as close to the desired\n\t// state as it was possible) or to revert them (a proper transaction).\n\tTransactionType() UpdateTransactionType\n\n\t// Direction determines the direction in which the event should flow through\n\t// the event handlers.\n\tDirection() UpdateDirectionType\n}\n```\nUpdateEvent can be reacted to by an incremental change, as opposed to the full re-synchronization.\n\n```go\ntype UpdateOperations interface {\n\tResyncOperations\n\n\t// Delete adds request to the transaction to delete an existing value.\n\tDelete(key string)\n}\n```\nUpdateOperations lists operations needed to build transaction for Update-type events.\n\n```go\ntype UpdateTransactionType int\n```\nUpdateTransactionType is either BestEffort or RevertOnFailure.\n\n```go\nconst (\n\t// BestEffort transaction continues even if non-fatal, non-abort error\n\t// is returned (to get as close to the desired state as it is possible).\n\t// After an errored BestEffort transaction, a healing resync is triggered.\n\tBestEffort UpdateTransactionType = iota\n\n\t// BestEffortIgnoreErrors is the same as BestEffort, but healing resync\n\t// is NOT triggered in case of errors.\n\tBestEffortIgnoreErrors\n\n\t// RevertOnFailure tells the Controller to stop event processing when any error\n\t// is returned and to revert already executed changes.\n\tRevertOnFailure\n)\n```\n\n```go\ntype VerificationResync struct {\n}\n```\nVerificationResync is used to verify the preservation of state consistency of Contiv plugins after any event.\n\n```go\nfunc (ev *VerificationResync) Done(error)\n```\nDone is NOOP.\n\n```go\nfunc (ev *VerificationResync) GetName() string\n```\nGetName returns name of the VerificationResync event.\n\n```go\nfunc (ev *VerificationResync) IsBlocking() bool\n```\nIsBlocking returns false.\n\n```go\nfunc (ev *VerificationResync) Method() EventMethodType\n```\nMethod is UpstreamResync.\n\n```go\nfunc (ev *VerificationResync) String() string\n```\nString describes VerificationResync event.\n\n","path":"github.com/contiv/vpp/plugins/controller/api","name":"api","synopsis":"","isRedistributable":true}
