subscribe

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 19 Imported by: 13

Documentation

Overview

Package subscribe implements the gnmi.proto Subscribe service API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ClientStats

type ClientStats struct {
	Target        string // for which target
	CoalesceCount int64  // total coalsced updates for the client, cumulative
	QueueSize     int64  // current queue size for the client
}

ClientStats is the container of statistics for a particular client.

type Option

type Option func(*options)

Option defines the function prototype to set options for creating a Server.

func WithACL

func WithACL(a ACL) Option

WithACL sets server ACL.

func WithClientStatsTest

func WithClientStatsTest(f func(int64, int64)) Option

WithClientStatsTest test override function.

func WithFlowControlTest

func WithFlowControlTest(f func()) Option

WithFlowControlTest returns an Option to override a test function to simulate flow control.

func WithStats

func WithStats() Option

WithStats returns an Option to enable statistics collection of client queries to the server.

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout returns an Option to specify how long a send can be pending before the RPC is closed.

func WithUpdateSubsCountEnterTest

func WithUpdateSubsCountEnterTest(f func()) Option

WithUpdateSubsCountEnterTest test override function.

func WithUpdateSubsCountExitTest

func WithUpdateSubsCountExitTest(f func()) Option

WithUpdateSubsCountExitTest test override function.

func WithoutDupReport

func WithoutDupReport() Option

WithoutDupReport returns an Option to disable reporting of duplicates in the responses to the clients. When duplicate reporting is disabled, there is no need to clone the Notification proto message for setting a non-zero field "duplicates" in a response sent to clients, which can potentially save CPU cycles.

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, opts ...Option) (*Server, error)

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

func (*Server) ClientStats

func (s *Server) ClientStats() map[string]ClientStats

ClientStats returns states of all subscribe clients such as queue size, coalesce count. Statistics is available only if the Server is created with NewServerWithStats.

func (*Server) MakeSubscribeResponse

func (s *Server) 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 (*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) TargetStats

func (s *Server) TargetStats() map[string]TargetStats

TargetStats returns statistics of subscribe queries for all targets. Statistics is available only if the Server is created with NewServerWithStats.

func (*Server) TypeStats

func (s *Server) TypeStats() map[string]TypeStats

TypeStats returns statistics for all types of subscribe queries, e.g. stream, once, or poll. Statistics is available only if the Server is created with NewServerWithStats.

func (*Server) Update

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

Update passes a streaming update to registered clients.

type TargetStats

type TargetStats struct {
	ActiveSubscriptionCount int64 // currently active subscription count
	SubscriptionCount       int64 // total subscription count, cumulative
}

TargetStats is the container of client side statistics for a target.

type TypeStats

type TypeStats struct {
	ActiveSubscriptionCount int64 // currently active subscription count
	SubscriptionCount       int64 // total subscription count, cumulative
}

TypeStats is the container of client side statistics for a particular subscribe mode, e.g. stream, once, or poll.

Jump to

Keyboard shortcuts

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