Documentation ¶
Index ¶
Constants ¶
const PipelineBufSize = 4
Variables ¶
This section is empty.
Functions ¶
func IsChannelOpen ¶
IsChannelOpen checks if the channel is open
func MustReturn ¶
func PanicIfErr ¶
func PanicIfErr(err error)
Types ¶
type Cleanup ¶
type Cleanup struct {
// contains filtered or unexported fields
}
func NewCleanup ¶
func NewCleanup(cl func()) *Cleanup
func NewCleanupErr ¶
type Pipeline ¶
type Pipeline[T any] struct { // contains filtered or unexported fields }
Pipeline is an extension of Go channels that implements a channel with an infinite buffer. You need to call the `Start` method to start the channel, otherwise `Put` method will panic. It then behaves like a regular channel: `Put` method is used to submit messages, unlike regular channels it never blocks. `ReadChan` method can be used to get the read side of this pipeline. `Stop` method stops the pipeline. Unlike the regular channels, `Stop` method does not guarantee that all the pending messages are consumed.
func (*Pipeline[T]) Put ¶
func (p *Pipeline[T]) Put(elem T)
Put enqueues the message into the pipeline. Unlike the regular channel write, it's a simple no-op if the pipeline has been stopped already
func (*Pipeline[T]) PutFront ¶
func (p *Pipeline[T]) PutFront(elem T)
PutFront enqueues the message into the front of the pipeline
func (*Pipeline[T]) ReadChan ¶
func (p *Pipeline[T]) ReadChan() <-chan T
ReadChan gets the read side of this pipeline