Documentation ¶
Index ¶
- type CachingMap
- func (c *CachingMap[K, V]) ApplyAllChanges() error
- func (c *CachingMap[K, V]) ApplyDeletionsOnly() error
- func (c *CachingMap[K, V]) ApplyUpdatesOnly() error
- func (c *CachingMap[K, V]) DeleteAllDesired()
- func (c *CachingMap[K, V]) DeleteDesired(k K)
- func (c *CachingMap[K, V]) GetDataplaneCache(k K) (V, bool)
- func (c *CachingMap[K, V]) IterDataplaneCache(f func(k K, v V))
- func (c *CachingMap[K, V]) LoadCacheFromDataplane() error
- func (c *CachingMap[K, V]) SetDesired(k K, v V)
- type DataplaneMap
- type ErrSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachingMap ¶
type CachingMap[K comparable, V comparable] struct { // contains filtered or unexported fields }
CachingMap provides a caching layer around a DataplaneMap, when one of the Apply methods is called, it applies a minimal set of changes to the dataplane map to bring it into sync with the desired state. Updating the desired state in and of itself has no effect on the dataplane.
CachingMap will load a cache of the dataplane state on the first call to ApplyXXX, or the cache can be loaded explicitly by calling LoadCacheFromDataplane(). This allows for client code to inspect the dataplane cache with IterDataplaneCache and GetDataplaneCache.
func New ¶
func New[K comparable, V comparable](name string, dpMap DataplaneMap[K, V]) *CachingMap[K, V]
func (*CachingMap[K, V]) ApplyAllChanges ¶
func (c *CachingMap[K, V]) ApplyAllChanges() error
ApplyAllChanges attempts to bring the dataplane map into sync with the desired state.
func (*CachingMap[K, V]) ApplyDeletionsOnly ¶
func (c *CachingMap[K, V]) ApplyDeletionsOnly() error
ApplyDeletionsOnly applies any pending deletions to the dataplane map. It doesn't add or update any keys that are new/changed.
func (*CachingMap[K, V]) ApplyUpdatesOnly ¶
func (c *CachingMap[K, V]) ApplyUpdatesOnly() error
ApplyUpdatesOnly applies any pending adds/updates to the dataplane map. It doesn't delete any keys that are no longer wanted.
func (*CachingMap[K, V]) DeleteAllDesired ¶
func (c *CachingMap[K, V]) DeleteAllDesired()
DeleteAllDesired deletes all entries from the in-memory desired state of the map. It doesn't actually touch the dataplane.
func (*CachingMap[K, V]) DeleteDesired ¶
func (c *CachingMap[K, V]) DeleteDesired(k K)
DeleteDesired deletes the given key from the desired state of the dataplane. This is an in-memory operation, it doesn't actually touch the dataplane.
func (*CachingMap[K, V]) GetDataplaneCache ¶
func (c *CachingMap[K, V]) GetDataplaneCache(k K) (V, bool)
GetDataplaneCache gets a single value from the cache of the dataplane. The cache must have previously been loaded with a successful call to LoadCacheFromDataplane() or one of the ApplyXXX methods.
func (*CachingMap[K, V]) IterDataplaneCache ¶
func (c *CachingMap[K, V]) IterDataplaneCache(f func(k K, v V))
IterDataplaneCache iterates over the cache of the dataplane. The cache must have previously been loaded with a successful call to LoadCacheFromDataplane() or one of the ApplyXXX methods.
func (*CachingMap[K, V]) LoadCacheFromDataplane ¶
func (c *CachingMap[K, V]) LoadCacheFromDataplane() error
LoadCacheFromDataplane loads the contents of the DP map into the dataplane cache, allowing it to be queried with GetDataplaneCache and IterDataplaneCache.
func (*CachingMap[K, V]) SetDesired ¶
func (c *CachingMap[K, V]) SetDesired(k K, v V)
SetDesired sets the desired state of the given key to the given value. This is an in-memory operation, it doesn't actually touch the dataplane.
type DataplaneMap ¶
type DataplaneMap[K comparable, V comparable] interface { Update(K, V) error Delete(K) error Load() (map[K]V, error) ErrIsNotExists(error) bool }
DataplaneMap is an interface of the underlying map that is being cached by the CachingMap. It implements interaction with the dataplane.