Documentation
¶
Index ¶
- func BufferedPipe[T any](ctx context.Context) (chan<- T, <-chan T)
- func Pipe[T any](ctx context.Context, inC <-chan T, outC chan<- T) bool
- func PipeAll[T any](ctx context.Context, inC <-chan T, outC chan<- T)
- func Pipeline[R any, T any](ctx context.Context, inC <-chan R, outC chan<- T, ...) (bool, error)
- func PipelineAll[R any, T any](ctx context.Context, inC <-chan R, outC chan<- T, ...) error
- func Receive[T any](ctx context.Context, inC <-chan T) (T, bool)
- func Submit[T any](ctx context.Context, channel chan<- T, value T) bool
- type ConcurrencyLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BufferedPipe ¶
BufferedPipe is a generic, channel and deque buffered pipe implementation.
func Pipe ¶
Pipe is a context aware fused Receive and Submit operation. The function will attempt to receive from the passed readable channel and then submit it to the writable channel. If the context expires during either of these operations this function will return false.
func PipeAll ¶
PipeAll is a convenience function that exhausts the passed readable channel by piping the received values to passed writable channel.
func Pipeline ¶
func Pipeline[R any, T any](ctx context.Context, inC <-chan R, outC chan<- T, convertor func(raw R) (T, error)) (bool, error)
Pipeline is a function that operates similarly to a Pipe but allows conversion from the readable channel's type: R to the writable channel's type: T through a passed convertor delegate. Errors from the convertor delegate are returned to the caller.
Conversion failure will result in a receive from the readable channel without a corresponding submit to the writable channel.
func PipelineAll ¶
func PipelineAll[R any, T any](ctx context.Context, inC <-chan R, outC chan<- T, convertor func(raw R) (T, error)) error
PipelineAll is a convenience function that exhausts the passed readable channel by pipelining the received values to the passed writable channel.
func Receive ¶
Receive takes a valid context.Context, a readable channel and attempts to receive a new value from it. If the function successfully receives the value before the context expires, this function will return both the value and true. If, however the context expires before the function can receive from the channel, or if the channel is closed, this function return false. Both conditions are not explicitly considered errors. It is up to the caller to interpret the return values further.
func Submit ¶
Submit takes a valid context.Context, a writeable channel and attempts to submit the passed value to it. If the function successfully submits the value before the context expires, this function will return true. If, however the context expires before the function can submit to the channel this function return false. Context expiration is not explicitly considered an error. It is up to the caller to interpret the return value further.
Types ¶
type ConcurrencyLimiter ¶
type ConcurrencyLimiter struct {
// contains filtered or unexported fields
}
func NewConcurrencyLimiter ¶
func NewConcurrencyLimiter(numSlots int) ConcurrencyLimiter
func (ConcurrencyLimiter) Release ¶
func (s ConcurrencyLimiter) Release()