subscribe

package
v0.0.0-...-518e166 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package subscribe implements the gnmi.proto Subscribe service API. This is a forked version of github.com/openconfig/gnmi's subscribe package to add a means to have local (non-network) subscribers to the cache, as well as host a specific set of "tasks" that produce that telemetry information. It requires internal access to the cache - which exposes the upstream implementation to new public APIs, and hence we make these changes in this forked copy.

Index

Constants

This section is empty.

Variables

View Source
var (

	// Timeout specifies how long a send can be pending before the RPC is closed.
	Timeout = time.Minute
	// SubscriptionLimit specifies how many queries can be processing simultaneously.
	// This number includes Once queries, Polling subscriptions, and Streaming
	// subscriptions that have not yet synced. Once a streaming subscription has
	// synced, it no longer counts against the limit. A polling subscription
	// counts against the limit during each polling cycle while it is processed.
	SubscriptionLimit = 0
)

Functions

func MakeSubscribeResponse

func MakeSubscribeResponse(n interface{}, dup uint32) (*pb.SubscribeResponse, error)

MakeSubscribeResponse produces a gnmi_proto.SubscribeResponse from a gnmi_proto.Notification.

This function modifies the message to set the duplicate count if it is greater than 0. The function clones the gnmi notification if the duplicate count needs to be set. You have to be working on a cloned message if you need to modify the message in any way.

func UpdateNotification

func UpdateNotification(m *match.Match, v interface{}, n *pb.Notification, prefix []string)

UpdateNotification uses paths in a pb.Notification n to match registered clients in m and pass value v to those clients. prefix is the prefix of n that should be used to match clients in m. Depending on the caller, the target may or may not be in prefix. v should be n itself or the container of n (e.g. a ctree.Leaf) depending on the caller.

Types

type ACL

type ACL interface {
	NewRPCACL(context.Context) (RPCACL, error)
	Check(string, string) bool
}

ACL is server ACL interface

type RPCACL

type RPCACL interface {
	Check(string) bool
}

RPCACL is the per RPC ACL interface

type Server

type Server struct {
	pb.UnimplementedGNMIServer // Stub out all RPCs except Subscribe.
	// contains filtered or unexported fields
}

Server is the implementation of the gNMI Subcribe API.

func NewServer

func NewServer(c *cache.Cache) (*Server, error)

NewServer instantiates server to handle client queries. The cache should be already instantiated.

func (*Server) SetACL

func (s *Server) SetACL(a ACL)

SetACL sets server ACL. This method is called before server starts to run.

func (*Server) Subscribe

func (s *Server) Subscribe(stream pb.GNMI_SubscribeServer) error

Subscribe is the entry point for the external RPC request of the same name defined in gnmi.proto.

func (*Server) SubscribeLocal

func (s *Server) SubscribeLocal(target string, paths []*pb.Path, prefix *pb.Path) (*coalesce.Queue, func(), error)

SubscribeLocal registers a set of paths to listen to. It returns a coalescing queue object into which the updates will be sent, and a remove function that stops the queue from being updated.

func (*Server) Update

func (s *Server) Update(n *ctree.Leaf)

Update passes a streaming update to registered clients.

Jump to

Keyboard shortcuts

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