queue

package
Version: 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: 7 Imported by: 0

Documentation

Overview

Package queue implements an update queue for use in testing a telemetry stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypedValueOf

func TypedValueOf(v *fpb.Value) *gpb.TypedValue

TypedValueOf returns the gNMI TypedValue of v. If v is a Sync or Delete, TypedValueOf returns nil.

func ValueOf

func ValueOf(v *fpb.Value) interface{}

ValueOf returns the concrete value of v.

Types

type FixedQueue

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

FixedQueue provides a strict delivery of provides updates. If checkDelay, the Next() will sleep for the duration between the timestamps provided in the updates.

func NewFixed

func NewFixed(resp []*gpb.SubscribeResponse, delay bool) *FixedQueue

NewFixed creates a new FixedQueue with resp list of updates enqueued for iterating through.

func (*FixedQueue) Add

func (q *FixedQueue) Add(resp *gpb.SubscribeResponse)

Add will append resp to the current tail of the queue.

func (*FixedQueue) Next

func (q *FixedQueue) Next() (interface{}, error)

Next returns the next update in the queue or an error. If the queue is exhausted, a nil is returned for the update. The return will always be a *gpb.SubscribeResponse for proper type assertion.

type Queue

type Queue interface {
	Next() (interface{}, error)
}

Queue is a generic interface for getting the next element from either a FixedQueue or UpdateQueue.

type UpdateQueue

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

UpdateQueue is a structure that orders a set of device updates by their timestamps and repeatedly generates new pseudo-random updates based on a set of device path configurations.

func New

func New(delay bool, seed int64, values []*fpb.Value) *UpdateQueue

New creates a new UpdateQueue. If delay is true, a call to Next() will invoke a sleep based on the duration between timestamps of the last returned update and the update to be returned by the current call. The values are the configuration for the updates stored in the queue.

func (*UpdateQueue) Add

func (u *UpdateQueue) Add(v *fpb.Value)

Add inserts v into the queue in correct timestamp order.

func (*UpdateQueue) Latest

func (u *UpdateQueue) Latest() int64

Latest returns the maximum timestamp in the queue.

func (*UpdateQueue) Next

func (u *UpdateQueue) Next() (interface{}, error)

Next returns the next update in the queue or an error. If the queue is exhausted, a nil is returned for the update. The return will always be a *fpb.Value for proper type assertion.

Jump to

Keyboard shortcuts

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