DefaultChanBufferSize is the default buffer size of the underlying channel.
const DefaultChanBufferSize = 1
func MustParseURL(target string) *url.URL
MustParseURL attempts to parse the provided target using url.Parse() and panics if parsing fails.
Channel wraps a generic channel and provides a timed receive operation.
type Channel struct {
// contains filtered or unexported fields
}
func NewChannel() *Channel
NewChannel returns a new Channel.
func NewChannelWithSize(bufSize int) *Channel
NewChannelWithSize returns a new Channel with a buffer of bufSize.
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 (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 (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 (c *Channel) Send(value interface{})
Send sends value on the underlying channel.
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 (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.