cache

package
v0.0.0-...-aed1ee4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func T

func T(n int64) time.Time

T provides a shorthand function to reference a timestamp with an int64 (nanoseconds since epoch).

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a structure holding state information for multiple targets.

func New

func New(targets []string) *Cache

New creates a new instance of Cache that receives target updates from the translator and provides an interface to service client queries.

func (*Cache) Add

func (c *Cache) Add(target string) *Target

Add reserves space in c to receive updates for the specified target.

func (*Cache) Connect

func (c *Cache) Connect(name string)

Connect creates an internal gnmi.Notification for metadata/connected path to set the state to true for the specified target.

func (*Cache) GetTarget

func (c *Cache) GetTarget(target string) *Target

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

func (c *Cache) HasTarget(target string) bool

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) Metadata

func (c *Cache) Metadata() map[string]*metadata.Metadata

Metadata returns the per-target metadata structures.

func (*Cache) Query

func (c *Cache) Query(target string, query []string, fn ctree.VisitFunc) error

Query calls the specified callback for all results matching the query. All values passed to fn are client.Notification.

func (*Cache) Remove

func (c *Cache) Remove(target string)

Remove removes the space in c corresponding to the specified target.

func (*Cache) Reset

func (c *Cache) Reset(target string)

Reset clears the cache for a target once a connection is resumed after having been lost.

func (*Cache) SetClient

func (c *Cache) SetClient(client func(*ctree.Leaf))

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

func (c *Cache) Sync(name string)

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.

func (*Target) Reset

func (t *Target) Reset()

Reset clears the Target of stale data upon a reconnection and notifies cache client of the removal.

func (*Target) Sync

func (t *Target) Sync()

Sync creates an internal gnmi.Notification with metadata/sync path to set the state to true for the specified target.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL