Documentation ¶
Overview ¶
Package datasync defines the datasync API, which abstracts the data transport between app plugins and backend data sources. Data sources can be data stores, clients connected to a message bus, or remote clients connected to a CN-Infra app. Transport can be, for example, HTTP or gRPC.
These events are processed asynchronously. The app plugin that watches data changes gives callback for each event (e.g. successful configuration or an error).
See the examples under the dedicated examples package.
Index ¶
- Constants
- type AggregatedRegistration
- type CallbackResult
- type ChangeEvent
- type ChangeValue
- type CompositeKVProtoWatcher
- type CompositeKVProtoWriter
- type DelOption
- type DelOptionMarker
- type KeyProtoValWriter
- type KeyVal
- type KeyValIterator
- type KeyValProtoWatcher
- type LazyValue
- type LazyValueWithRev
- type ProtoWatchResp
- type PutDel
- type PutOption
- type PutOptionMarker
- type ResyncEvent
- type WatchRegistration
- type WithChangeType
- type WithKey
- type WithPrefixOpt
- type WithPrevValue
- type WithRevision
- type WithTTLOpt
Constants ¶
DefaultNotifTimeout for delivery of notification
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatedRegistration ¶
type AggregatedRegistration struct {
Registrations []WatchRegistration
}
AggregatedRegistration is cumulative adapter which contains all available transport types
func (*AggregatedRegistration) Close ¶
func (wa *AggregatedRegistration) Close() error
Close every registration under watch aggregator
type CallbackResult ¶
type CallbackResult interface { // Done allows plugins that are processing data change/resync to send feedback // If there was no error the Done(nil) needs to be called. Use the noError=nil // definition for better readability, for example: // Done(noError). Done(error) }
CallbackResult can be used by an event receiver to indicate to the event producer whether an operation was successful (error is nil) or unsuccessful (error is not nil)
DoneMethod is reused later. There are at least two implementations DoneChannel, DoneCallback
type ChangeEvent ¶
type ChangeEvent interface { CallbackResult ProtoWatchResp }
ChangeEvent is used as the data type for the change channel (see the VPP Standard Plugins API). A data change event contains a key identifying where the change happened and two values for data stored under that key: the value *before* the change (previous value) and the value *after* the change (current value).
type ChangeValue ¶
type ChangeValue interface { LazyValueWithRev WithChangeType }
ChangeValue represents single propagated change.
type CompositeKVProtoWatcher ¶
type CompositeKVProtoWatcher struct {
Adapters []KeyValProtoWatcher
}
CompositeKVProtoWatcher is a slice of watchers
func (*CompositeKVProtoWatcher) Watch ¶
func (ta *CompositeKVProtoWatcher) Watch(resyncName string, changeChan chan ChangeEvent, resyncChan chan ResyncEvent, keyPrefixes ...string) (WatchRegistration, error)
Watch subscribes to every transport available within transport aggregator
type CompositeKVProtoWriter ¶
type CompositeKVProtoWriter struct {
Adapters []KeyProtoValWriter
}
CompositeKVProtoWriter is cumulative adapter which contains all available transport types
type DelOption ¶
type DelOption interface {
//DelOptionMark is just for marking implementation that it implements this interface
DelOptionMark()
}
DelOption defines options for Del operation. The particular options can be found below.
type DelOptionMarker ¶
type DelOptionMarker struct{}
DelOptionMarker is meant for anonymous composition in With*Opt structs
func (*DelOptionMarker) DelOptionMark ¶
func (marker *DelOptionMarker) DelOptionMark()
DelOptionMark is just for marking implementation that it implements this interface
type KeyProtoValWriter ¶
type KeyProtoValWriter interface { // Put to ETCD or any other data transport (from other Agent Plugins) Put(key string, data proto.Message, opts ...PutOption) error }
KeyProtoValWriter allows plugins to push their data changes to a data store.
type KeyVal ¶
type KeyVal interface { WithKey LazyValueWithRev }
KeyVal represents a single key-value pair
type KeyValIterator ¶
type KeyValIterator interface { // GetNext retrieves the next value from the iterator context. The retrieved // value is unmarshaled into the provided argument. The allReceived flag is // set to true on the last KeyVal pair in the context. GetNext() (kv KeyVal, allReceived bool) }
KeyValIterator is an iterator for KeyVals
type KeyValProtoWatcher ¶
type KeyValProtoWatcher interface { // Watch using ETCD or any other data transport Watch(resyncName string, changeChan chan ChangeEvent, resyncChan chan ResyncEvent, keyPrefixes ...string) (WatchRegistration, error) }
KeyValProtoWatcher is used by plugin to subscribe to both data change events and data resync events. Multiple keys can be specified, the caller will be subscribed to events on each key. See README.md for description of the Events.
type LazyValue ¶
type LazyValue interface { // GetValue gets the current in the data change event. // The caller must provide an address of a proto message buffer // for each value. // returns: // - revision associated with the latest change in the key-value pair // - error if value argument can not be properly filled GetValue(value proto.Message) error }
LazyValue defines value that is unmarshalled into proto message on demand. The reason for defining interface with only one method is primary to unify interfaces in this package
type LazyValueWithRev ¶
type LazyValueWithRev interface { LazyValue WithRevision }
LazyValueWithRev defines value that is unmarshalled into proto message on demand with a revision. The reason for defining interface with only one method is primary to unify interfaces in this package
type ProtoWatchResp ¶
type ProtoWatchResp interface { ChangeValue WithKey WithPrevValue }
ProtoWatchResp contains changed value
type PutDel ¶
type PutDel string
PutDel enumerates 'Put' (meaning 'Create' or 'Update') and 'Delete' operations
type PutOption ¶
type PutOption interface {
//PutOptionMark is just for marking implementation that it implements this interface
PutOptionMark()
}
PutOption defines options for Put operation. The particular options can be found below.
type PutOptionMarker ¶
type PutOptionMarker struct{}
PutOptionMarker is meant for anonymous composition in With*Opt structs
func (*PutOptionMarker) PutOptionMark ¶
func (marker *PutOptionMarker) PutOptionMark()
PutOptionMark is just for marking implementation that it implements this interface
type ResyncEvent ¶
type ResyncEvent interface { CallbackResult GetValues() map[string]KeyValIterator }
ResyncEvent is used as the data type for the resync channel (see the ifplugin API)
type WatchRegistration ¶
WatchRegistration is a facade that avoids importing the io.Closer package into Agent plugin implementations.
type WithChangeType ¶
type WithChangeType interface {
GetChangeType() PutDel
}
WithChangeType is a helper interface which intent is to ensure that same method declaration is used in different interfaces (composition of interfaces)
type WithKey ¶
type WithKey interface { // GetKey returns the key of the pair GetKey() string }
WithKey is a helper interface which intent is to ensure that same method declaration is used in different interfaces (composition of interfaces)
type WithPrefixOpt ¶
type WithPrefixOpt struct {
DelOptionMarker
}
WithPrefixOpt applies an operation to all items with the specified prefix.
func WithPrefix ¶
func WithPrefix() *WithPrefixOpt
WithPrefix creates new instance of WithPrefixOpt.
type WithPrevValue ¶
type WithPrevValue interface { // GetPrevValue gets previous value in the data change event. // The caller must provide an address of a proto message buffer // for each value. // returns: // - prevValueExist flag is set to 'true' if prevValue was filled // - error if value argument can not be properly filled GetPrevValue(prevValue proto.Message) (prevValueExist bool, err error) }
WithPrevValue is a helper interface which intent is to ensure that same method declaration is used in different interfaces (composition of interfaces)
type WithRevision ¶
type WithRevision interface { // GetRevision gets revision of current value GetRevision() (rev int64) }
WithRevision is a helper interface which intent is to ensure that same method declaration is used in different interfaces (composition of interfaces)
type WithTTLOpt ¶
type WithTTLOpt struct { PutOptionMarker TTL time.Duration }
WithTTLOpt defines a TTL for data being put. Once TTL elapses the data is removed from data store.
func WithTTL ¶
func WithTTL(TTL time.Duration) *WithTTLOpt
WithTTL creates new instance of TTL option. Once TTL elapses data is removed. Beware: some implementation might be using TTL with lower precision.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package grpcsync implements (in ALPHA VERSION) the gRPC transport client and server that satisfy the datasync API.
|
Package grpcsync implements (in ALPHA VERSION) the gRPC transport client and server that satisfy the datasync API. |
Package kvdbsync implements the key-value data store client and server that satisfythe datasync API.
|
Package kvdbsync implements the key-value data store client and server that satisfythe datasync API. |
local
Package local implements DB Transactions for the local "in memory" transport.
|
Package local implements DB Transactions for the local "in memory" transport. |
Package restsync implements (in ALPHA VERSION) the datasync API for the HTTP/REST transport.
|
Package restsync implements (in ALPHA VERSION) the datasync API for the HTTP/REST transport. |
Package resync implements the mechanism to notify previously registered plugins that the resync procedure needs to start.
|
Package resync implements the mechanism to notify previously registered plugins that the resync procedure needs to start. |
Package syncbase defines common structures used in multiple datasync transports.
|
Package syncbase defines common structures used in multiple datasync transports. |
msg
Package msg is a generated protocol buffer package.
|
Package msg is a generated protocol buffer package. |