testutils

package
v0.0.0-...-0e5e1e9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChanBufferSize = 1

DefaultChanBufferSize is the default buffer size of the underlying channel.

Variables

This section is empty.

Functions

func MustParseURL

func MustParseURL(target string) *url.URL

MustParseURL attempts to parse the provided target using url.Parse() and panics if parsing fails.

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 (c *Channel) Receive(ctx context.Context) (interface{}, error)

Receive returns the value received on the underlying channel, or the error returned by ctx if it is closed or cancelled.

func (*Channel) ReceiveOrFail

func (c *Channel) ReceiveOrFail() (interface{}, bool)

ReceiveOrFail returns the value on the underlying channel and true, or nil and false if the channel was empty.

func (*Channel) Replace

func (c *Channel) Replace(value interface{})

Replace clears the value on the underlying channel, and sends the new value.

It's expected to be used with a size-1 channel, to only keep the most up-to-date item. This method is inherently racy when invoked concurrently from multiple goroutines.

func (*Channel) Send

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

Send sends value on the underlying channel.

func (*Channel) SendContext

func (c *Channel) SendContext(ctx context.Context, value interface{}) error

SendContext sends value on the underlying channel, or returns an error if the context expires.

func (*Channel) SendOrFail

func (c *Channel) SendOrFail(value interface{}) bool

SendOrFail attempts to send value on the underlying channel. Returns true if successful or false if the channel was full.

Jump to

Keyboard shortcuts

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