package testutils

import "google.golang.org/grpc/xds/internal/testutils"

Package testutils provides utility types, for use in xds tests.

Index

Constants

const (
	// DefaultChanRecvTimeout is the default timeout for receive operations on the
	// underlying channel.
	DefaultChanRecvTimeout = 1 * time.Second
	// DefaultChanBufferSize is the default buffer size of the underlying channel.
	DefaultChanBufferSize = 1
)

Variables

var ErrRecvTimeout = errors.New("timed out when waiting for value on channel")

ErrRecvTimeout is an error to indicate that a receive operation on the channel timed out.

Types

type Channel

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

Channel wraps a generic channel and provides a timed receive operation.

func NewChannel

func NewChannel() *Channel

NewChannel returns a new Channel.

func NewChannelWithSize

func NewChannelWithSize(bufSize int) *Channel

NewChannelWithSize returns a new Channel with a buffer of bufSize.

func (*Channel) Receive

func (cwt *Channel) Receive() (interface{}, error)

Receive returns the value received on the underlying channel, or ErrRecvTimeout if DefaultChanRecvTimeout amount of time elapses.

func (*Channel) Send

func (cwt *Channel) Send(value interface{})

Send sends value on the underlying channel.

func (*Channel) TimedReceive

func (cwt *Channel) TimedReceive(timeout time.Duration) (interface{}, error)

TimedReceive returns the value received on the underlying channel, or ErrRecvTimeout if timeout amount of time elapsed.

Source Files

channel.go

Directories

PathSynopsis
xds/internal/testutils/fakeclientPackage fakeclient provides a fake implementation of an xDS client.
xds/internal/testutils/fakeserverPackage fakeserver provides a fake implementation of an xDS server.
Version
v1.29.0-dev
Published
Mar 5, 2020
Platform
linux/amd64
Imports
2 packages
Last checked
13 minutes ago

Tools for package owners.