Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is returned from calls to a service or interface in the event // that the Close() function has already been called. ErrClosed = errors.New("value sink is closing or already closed") )
Functions ¶
This section is empty.
Types ¶
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink represents a threadsafe value container that can receive updates. It is intended to be used in conjuction with an external trigger or polling function that updates the contained value.
Sink always stores the last non-nil value provided via update for which there was no associated error. This value can be retrieved by calling the value function.
It is safe to intialize a sink with its zero value or to embed a sink in other types.
func (*Sink) Update ¶
Update will update the value contained in the sink and unblock any oustanding calls to WaitReady.
func (*Sink) Value ¶
Value returns the current value if the sink is not empty, otherwise it returns nil.
Calls to this function are guaranteed to succeed if the sink is ready, as indicated by Sink.Ready().
func (*Sink) WaitReady ¶
WaitReady blocks until the next call to Update if the sink isn't ready, otherwise WaitReady does nothing and does not block.
WaitReady returns nil when the sink is ready with a value. If a call to Update provides an error, WaitReady unblocks and returns that error.
If the sink does not contain a value and has been closed then ErrClosed will be returned.