Documentation ¶
Overview ¶
Package channel is a go-like channel with flexible capacity contraints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LetItGo ¶
LetItGo defines a CapacityBehaviourFunc that ignores the capacity and simply continues to add the internal buffer.
func RemoveNewest ¶
RemoveNewest defines a CapacityBehaviourFunc that throws away the new element.
func RemoveOldest ¶
RemoveOldest defines a CapacityBehaviourFunc that removes the oldest entry and adds the new element to the internal buffer.
Types ¶
type CapacityBehaviourFunc ¶
CapacityBehaviourFunc defines the function called when the channel is at capacity. elem - the next element to be processed; buf - internal queue buffer.
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel is a augmented go-like channel.
func New ¶
New creates a new channel. The default channel is an infinite capacity channel with no at-capacity behaviour and no size alerts.
func (*Channel) Close ¶
func (ch *Channel) Close()
Close stops the internal contoller mechanism within channel. needs to be called at least once to allow the goroutine to exit.
type Option ¶
type Option func(*options)
Option configures aspects of the channel.
func Capacity ¶
func Capacity(capacity int, atCapFunc CapacityBehaviourFunc) Option
Capacity returns an Option that sets the capacity of the channel and its at-capacity behaviour.
func SizeAlert ¶
func SizeAlert(threshold int, alertFunc SizeAlertFunc) Option
SizeAlert returns a Option that sets the capacity alert threshold and alert function.
type SizeAlertFunc ¶
type SizeAlertFunc func(size int)
SizeAlertFunc defines the method is called when the internal buffer reaches an assigned threshold. size - the current size of the channel.