Documentation ¶
Overview ¶
Package cache is a tree-based cache of timestamped state provided from one or more gNMI targets. It accepts updates from the target(s) to refresh internal values that are made available to clients via subscriptions.
Index ¶
- func T(n int64) time.Time
- type Cache
- func (c *Cache) Add(target string) *Target
- func (c *Cache) Connect(name string)
- func (c *Cache) ConnectError(name string, err error)
- func (c *Cache) GetTarget(target string) *Target
- func (c *Cache) GnmiUpdate(n *pb.Notification) error
- func (c *Cache) HasTarget(target string) bool
- func (c *Cache) LatencyWindows() []time.Duration
- func (c *Cache) Metadata() map[string]*metadata.Metadata
- func (c *Cache) Query(target string, query []string, fn octree.VisitFunc) error
- func (c *Cache) Remove(target string)
- func (c *Cache) Reset(target string)
- func (c *Cache) SetClient(client func(*octree.Leaf))
- func (c *Cache) Sync(name string)
- func (c *Cache) UpdateMetadata()
- func (c *Cache) UpdateSize()
- type Option
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a structure holding state information for multiple targets.
func New ¶
New creates a new instance of Cache that receives target updates from the translator and provides an interface to service client queries.
func (*Cache) Connect ¶
Connect creates an internal gnmi.Notification for metadata/connected path to set the state to true for the specified target.
func (*Cache) ConnectError ¶
ConnectError updates the target's metadata with the provided error.
func (*Cache) GetTarget ¶
GetTarget returns the Target from the cache corresponding to the target name.
func (*Cache) GnmiUpdate ¶
func (c *Cache) GnmiUpdate(n *pb.Notification) error
GnmiUpdate sends a pb.Notification into the cache. If the notification has multiple Updates/Deletes, each individual Update/Delete is sent to cache as a separate gnmi.Notification.
func (*Cache) HasTarget ¶
HasTarget reports whether the specified target exists in the cache or a glob (*) is passed which will match any target (even if no targets yet exist).
func (*Cache) LatencyWindows ¶
LatencyWindows returns the latency windows supported by the cache.
func (*Cache) Query ¶
Query calls the specified callback for all results matching the query. All values passed to fn are client.Notification.
func (*Cache) Reset ¶
Reset clears the cache for a target once a connection is resumed after having been lost.
func (*Cache) SetClient ¶
SetClient registers a callback function to receive calls for each update accepted by the cache. This call should be made prior to sending any updates into the cache, just after initialization.
func (*Cache) Sync ¶
Sync creates an internal gnmi.Notification with metadata/sync path to set the state to true for the specified target.
func (*Cache) UpdateMetadata ¶
func (c *Cache) UpdateMetadata()
UpdateMetadata copies the current metadata for each target cache to the metadata path within each target cache.
func (*Cache) UpdateSize ¶
func (c *Cache) UpdateSize()
UpdateSize computes the size of each target cache and updates the size metadata reported within the each target cache.
type Option ¶
type Option func(*options)
Option defines the function prototype to set options for creating a Cache.
func WithAvgLatencyPrecision ¶
WithAvgLatencyPrecision returns an Option to set the precision of average latency stats calculated in Cache.
func WithLatencyWindows ¶
WithLatencyWindows returns an Option to set latency windows for which latency stats are calculated and exported for each target in Cache. metaUpdatePeriod is the period for updating target metadata. The latency windows need to be multiples of this period.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
A Target hosts an indexed cache of state for a single target.
func (*Target) Connect ¶
func (t *Target) Connect()
Connect creates an internal gnmi.Notification for metadata/connected path to set the state to true for the specified target, and clear connectErr.
func (*Target) GnmiUpdate ¶
func (t *Target) GnmiUpdate(n *pb.Notification) error
GnmiUpdate sends a pb.Notification into the target cache. If the notification has multiple Updates/Deletes, each individual Update/Delete is sent to cache as a separate gnmi.Notification.