Documentation ¶
Index ¶
- Constants
- func MustParseURL(target string) *url.URL
- type Channel
- func (c *Channel) Receive(ctx context.Context) (interface{}, error)
- func (c *Channel) ReceiveOrFail() (interface{}, bool)
- func (c *Channel) Replace(value interface{})
- func (c *Channel) Send(value interface{})
- func (c *Channel) SendContext(ctx context.Context, value interface{}) error
- func (c *Channel) SendOrFail(value interface{}) bool
Constants ¶
const DefaultChanBufferSize = 1
DefaultChanBufferSize is the default buffer size of the underlying channel.
Variables ¶
This section is empty.
Functions ¶
func MustParseURL ¶
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 NewChannelWithSize ¶
NewChannelWithSize returns a new Channel with a buffer of bufSize.
func (*Channel) Receive ¶
Receive returns the value received on the underlying channel, or the error returned by ctx if it is closed or cancelled.
func (*Channel) ReceiveOrFail ¶
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 ¶
SendContext sends value on the underlying channel, or returns an error if the context expires.
func (*Channel) SendOrFail ¶
SendOrFail attempts to send value on the underlying channel. Returns true if successful or false if the channel was full.