Documentation
¶
Overview ¶
Package subscribe implements the gnmi.proto Subscribe service API.
Index ¶
- func UpdateNotification(m *match.Match, v interface{}, n *pb.Notification, prefix []string)
- type ACL
- type ClientStats
- type Option
- func WithACL(a ACL) Option
- func WithClientStatsTest(f func(int64, int64)) Option
- func WithFlowControlTest(f func()) Option
- func WithStats() Option
- func WithTimeout(t time.Duration) Option
- func WithUpdateSubsCountEnterTest(f func()) Option
- func WithUpdateSubsCountExitTest(f func()) Option
- func WithoutDupReport() Option
- type RPCACL
- type Server
- func (s *Server) ClientStats() map[string]ClientStats
- func (s *Server) MakeSubscribeResponse(n interface{}, dup uint32) (*pb.SubscribeResponse, error)
- func (s *Server) Subscribe(stream pb.GNMI_SubscribeServer) error
- func (s *Server) TargetStats() map[string]TargetStats
- func (s *Server) TypeStats() map[string]TypeStats
- func (s *Server) Update(n *ctree.Leaf)
- type TargetStats
- type TypeStats
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 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 WithClientStatsTest ¶
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 ¶
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 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 ¶
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.
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.