server

package
v0.0.0-...-6d7b56c Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	gpb.UnimplementedGNMIServer
	// contains filtered or unexported fields
}

Server implements the GNMI gRPC server for testing purposes. It maintains an internal state that can be manipulated via gNMI requests or by modifying the internal state directly.

func NewTestServer

func NewTestServer(ctx context.Context) (*Server, error)

NewTestServer starts an in-process gNMI server on a random available port.

func (*Server) Capabilities

Capabilities returns the capabilities of the gNMI server

func (*Server) Close

func (s *Server) Close()

Close gracefully shuts down the server.

func (*Server) GRPCAddr

func (s *Server) GRPCAddr() string

GRPCAddr returns the gRPC server address

func (*Server) Get

func (s *Server) Get(_ context.Context, req *gpb.GetRequest) (*gpb.GetResponse, error)

Get returns the current state of the server for the requested path

func (*Server) Set

func (s *Server) Set(_ context.Context, req *gpb.SetRequest) (*gpb.SetResponse, error)

Set updates the state of the server for the requested path

func (*Server) State

func (s *Server) State() *State

State returns the internal state of the server Callers must use State's methods (Get, Set, Del) which handle locking.

func (*Server) Subscribe

Subscribe handles gNMI subscription requests.

type State

type State struct {
	sync.RWMutex

	Buf []byte
}

State represents a JSON body that can be manipulated using sjson syntax.

func (*State) Del

func (s *State) Del(path *gpb.Path) error

Del deletes the value at the specified path from the state.

func (*State) Get

func (s *State) Get(path *gpb.Path) []byte

Get retrieves the value at the specified path from the state.

func (*State) GetBuf

func (s *State) GetBuf() []byte

GetBuf returns a copy of the entire state buffer.

func (*State) Set

func (s *State) Set(path *gpb.Path, raw []byte) (err error)

Set sets the value at the specified path in the state.

func (*State) SetBuf

func (s *State) SetBuf(buf []byte)

SetBuf sets the entire state buffer to the provided value.

func (*State) Update

func (s *State) Update(path *gpb.Path, raw []byte) error

Update merges the value at the specified path without removing existing object fields.

Jump to

Keyboard shortcuts

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