Documentation ¶
Overview ¶
Package gnmit is a single-target gNMI collector implementation that can be used as an on-device/fake device implementation. It supports the Subscribe RPC using the libraries from openconfig/gnmi.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶
func NewServer(ctx context.Context, hostname string, sendMeta bool, tasks []Task) (*Collector, *GNMIServer, error)
New returns a new collector server implementation that can be registered on an existing gRPC server. It takes a string indicating the hostname of the target, a boolean indicating whether metadata should be sent, and a slice of tasks that are to be launched to run on the server.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is a basic gNMI target that supports only the Subscribe RPC, and acts as a cache for exactly one target.
func New ¶
func New(ctx context.Context, addr, hostname string, sendMeta bool, tasks []Task, opts ...grpc.ServerOption) (*Collector, string, error)
New returns a new collector that listens on the specified addr (in the form host:port), supporting a single downstream target named hostname. sendMeta controls whether the metadata *other* than meta/sync and meta/connected is sent by the collector.
New returns the new collector, the address it is listening on in the form hostname:port or any errors encounted whilst setting it up.
func (*Collector) TargetUpdate ¶
func (c *Collector) TargetUpdate(m *gpb.SubscribeResponse)
TargetUpdate provides an input gNMI SubscribeResponse to update the cache and clients with.
type GNMIServer ¶
type GNMIServer struct { // The subscribe Server implements only Subscribe for gNMI. *subscribe.Server // contains filtered or unexported fields }
GNMIServer implements the gNMI server interface.
func (*GNMIServer) RegisterTask ¶
func (s *GNMIServer) RegisterTask(task Task) error
RegisterTask starts up a task on the gNMI datastore.
type Queue ¶
type Queue interface { // Next returns a potential update to be sent, along with a count of duplicates // and any error that occurs. The update to be sent is reflected as an any // as it can be a leaf (*ctree.Leaf), a sync_response marker, and can be // extended in the future. Next(ctx context.Context) (any, uint32, error) Len() int Close() }
Queue is an interface that represents a possibly coalescing queue of updates.
type Task ¶
type Task struct { Run TaskRoutine Paths []ygot.PathStruct Prefix *gpb.Path }
Task defines a particular task that runs on the gNMI datastore.
type TaskRoutine ¶
TaskRoutine is a reactor function that listens for updates from a queue, emits updates via an update function. It does this on a target (string parameter), and also has a final clean-up function to call when it finishes processing.
type UpdateFn ¶
type UpdateFn func(*gpb.Notification) error
UpdateFn is a function that takes in a gNMI Notification object and updates a gNMI datastore with it.