gnmi

package
v0.0.0-...-aed1ee4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gnmi implements a gRPC gNMI agent for testing against a collector implementation. Each agent will generate a set of Value protocol buffer messages that create a queue of updates to be streamed from a synthetic device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	gnmipb.UnimplementedGNMIServer
	// contains filtered or unexported fields
}

Agent manages a single gNMI agent implementation. Each client that connects via Subscribe or Get will receive a stream of updates based on the requested path and the provided initial configuration.

func New

func New(config *fpb.Config, opts []grpc.ServerOption) (*Agent, error)

New returns an initialized fake agent.

func NewFromServer

func NewFromServer(s *grpc.Server, config *fpb.Config) (*Agent, error)

NewFromServer returns a new initialized fake agent from provided server.

func (*Agent) Address

func (a *Agent) Address() string

Address returns the port the agent is listening to.

func (*Agent) Close

func (a *Agent) Close()

Close shuts down the agent.

func (*Agent) Requests

func (a *Agent) Requests() []*gnmipb.SubscribeRequest

Requests returns the subscribe requests received by the most recently created client.

func (*Agent) State

func (a *Agent) State() fpb.State

State returns the current state of the agent.

func (*Agent) Subscribe

func (a *Agent) Subscribe(stream gnmipb.GNMI_SubscribeServer) error

Subscribe implements the gNMI Subscribe RPC.

func (*Agent) Target

func (a *Agent) Target() string

Target returns the target name the agent is faking.

func (*Agent) Type

func (a *Agent) Type() string

Type returns the target type the agent is faking.

type Client

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

Client contains information about a client that has connected to the fake.

func NewClient

func NewClient(config *fpb.Config) *Client

NewClient returns a new initialized client.

func (*Client) Close

func (c *Client) Close()

Close will cancel the client context and will cause the send and recv goroutines to exit.

func (*Client) Config

func (c *Client) Config() *fpb.Config

Config returns the current config of the client.

func (*Client) Run

func (c *Client) Run(stream gpb.GNMI_SubscribeServer) (err error)

Run starts the client. The first message received must be a SubscriptionList. Once the client is started, it will run until the stream is closed or the schedule completes. For Poll queries the Run will block internally after sync until a Poll request is made to the server. This is important as the test may look like a deadlock since it can cause a timeout. Also if you Reset the client the change will not take effect until after the previous queue has been drained of notifications.

func (*Client) SetConfig

func (c *Client) SetConfig(config *fpb.Config)

SetConfig will replace the current configuration of the Client. If the client is running then the change will not take effect until the queue is drained of notifications.

func (*Client) String

func (c *Client) String() string

String returns the target the client is querying.

Directories

Path Synopsis
cmd
fake_server
The fake_server is a simple gRPC gnmi agent implementation which will take a configuration and start a listening service for the configured target.
The fake_server is a simple gRPC gnmi agent implementation which will take a configuration and start a listening service for the configured target.
gen_fake_config
The gen_fake_config command converts a hardcoded fake.proto message into a textual protobuf.
The gen_fake_config command converts a hardcoded fake.proto message into a textual protobuf.

Jump to

Keyboard shortcuts

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