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) GetTarget(target string) *Target
- func (c *Cache) GnmiUpdate(n *pb.Notification) error
- func (c *Cache) HasTarget(target string) bool
- func (c *Cache) Metadata() map[string]*metadata.Metadata
- func (c *Cache) Query(target string, query []string, fn ctree.VisitFunc) error
- func (c *Cache) Remove(target string)
- func (c *Cache) Reset(target string)
- func (c *Cache) SetClient(client func(*ctree.Leaf))
- func (c *Cache) Sync(name string)
- func (c *Cache) UpdateMetadata()
- func (c *Cache) UpdateSize()
- 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) 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) 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 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.
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.