Documentation ¶
Overview ¶
Package schemafake defines a fake implementation of a gNMI device with a known schema which is used to validate tests within the gNMITest framework.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Timestamp is a function used to specify the timestamp to be used in Notifications // returned from the fake. It can be overridden in calling code to ensure that a // deterministic result is returned. Timestamp = func() int64 { return time.Now().UnixNano() } )
Functions ¶
This section is empty.
Types ¶
type Target ¶
type Target struct { gpb.UnimplementedGNMIServer // Implement the gNMI server interface. // contains filtered or unexported fields }
Target defines the gNMI fake target.
func New ¶
New creates a new schemaefake using the specified map of schemas. The schemas map is keyed by the origin name, with the value being a Schema specification.
func (*Target) Get ¶
func (t *Target) Get(ctx context.Context, r *gpb.GetRequest) (*gpb.GetResponse, error)
Get implements the gNMI Get RPC. The request received from the client is extracted from the GetRequest received from the client. Each path is retrieved from the target's data tree, and subsequently marshalled into a gNMI Notification. Each path in the GetRequest is handled separately, such that there is no guarantee of consistency across separate paths within the GetRequest. Prefixing is performed within the results of each path expansion within the request.
func (*Target) Load ¶
Load unmarshals the JSON supplied in b into the supplied origin, using the options specified into the target's root using the stored unmarshal function.
func (*Target) Start ¶
Start starts the fake gNMI server with the specified certificate and key. It returns the TCP port the fake is listening on, a function to stop the server and an optional error if the server cannot be started.
func (*Target) Subscribe ¶
func (t *Target) Subscribe(stream gpb.GNMI_SubscribeServer) error
Subscribe handles the gNMI bi-directional streaming Subscribe RPC. SubscribeRequest messages are read from the client, and the target streams responses back according to the type of subscription specified.
Currently, this implementation only supports the ONCE subscription mode.