fakegnmi

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fakegnmi implements a fake GNMI server with the ability to stub responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeGNMI

type FakeGNMI struct {
	// contains filtered or unexported fields
}

FakeGNMI is a running fake GNMI server.

func Start

func Start(port int) (*FakeGNMI, error)

Start launches a new fake GNMI server on the given port

func (*FakeGNMI) Dial

func (g *FakeGNMI) Dial(ctx context.Context, opts ...grpc.DialOption) (gpb.GNMIClient, error)

Dial dials the fake gNMI client and returns a gNMI client stub.

func (*FakeGNMI) GetRequests

func (g *FakeGNMI) GetRequests() []*gpb.GetRequest

GetRequests returns the set of GetRequests sent to the gNMI server.

func (*FakeGNMI) Requests

func (g *FakeGNMI) Requests() []*gpb.SubscribeRequest

Requests returns the set of SubscribeRequests sent to the gNMI server.

func (*FakeGNMI) Stub

func (g *FakeGNMI) Stub() *Stubber

Stub reset the stubbed responses to empty and returns a handle to add new ones.

type StubGNMI added in v0.1.23

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

StubGNMI is a running stub GNMI server. It doesn't implement correct subscribe mechanics, instead use Stub to insert subscribe responses.

func NewStubGNMI added in v0.1.23

func NewStubGNMI(srv *grpc.Server, lis net.Listener) *StubGNMI

NewStubGNMI creates a new stub gNMI server.

func StartStubGNMI added in v0.1.23

func StartStubGNMI(port int) (*StubGNMI, error)

StartStubGNMI starts serving a gNMI server at the given port.

func (*StubGNMI) Addr added in v0.1.23

func (g *StubGNMI) Addr() string

Addr returns the listener address of the server.

func (*StubGNMI) Get added in v0.1.23

func (g *StubGNMI) Get(ctx context.Context, req *gpb.GetRequest) (*gpb.GetResponse, error)

Get is stub implement of gnmi Get.

func (*StubGNMI) GetRequests added in v0.1.23

func (g *StubGNMI) GetRequests() []*gpb.GetRequest

GetRequests returns the set of GetRequests sent to the gNMI server.

func (*StubGNMI) Requests added in v0.1.23

func (g *StubGNMI) Requests() []*gpb.SubscribeRequest

Requests returns the set of SubscribeRequests sent to the gNMI server.

func (*StubGNMI) Stop added in v0.1.23

func (g *StubGNMI) Stop() error

Stop gracefully stops the server and closes the listener.

func (*StubGNMI) Stub added in v0.1.23

func (g *StubGNMI) Stub() *Stubber

Stub reset the stubbed responses to empty and returns a handle to add new ones.

func (*StubGNMI) Subscribe added in v0.1.23

func (g *StubGNMI) Subscribe(stream gpb.GNMI_SubscribeServer) error

Get is stub implement of gnmi Get.

type Stubber

type Stubber struct {
	// contains filtered or unexported fields
}

Stubber is a handle to add stubbed responses.

func (*Stubber) GetResponse

func (s *Stubber) GetResponse(gr *gpb.GetResponse) *Stubber

GetResponse appends the given GetResponse as a stub response.

func (*Stubber) Notification

func (s *Stubber) Notification(n *gpb.Notification) *Stubber

Notification appends the given notification as a stub response.

func (*Stubber) Sync

func (s *Stubber) Sync() *Stubber

Sync appends a sync stub response.

Jump to

Keyboard shortcuts

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