Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidMaxOps = errors.New("maximum operations per second has to be greater than zero") ErrDeliveryFuncNil = errors.New("delivery function is nil") )
Functions ¶
This section is empty.
Types ¶
type DeliveryFunc ¶
type DeliveryFunc = func(item interface{})
type DeliveryQueue ¶
type DeliveryQueue struct {
// contains filtered or unexported fields
}
DeliveryQueue is a queue with embedded rate limiter that guarantees that deliveryFunc will not be executed more than specified number of times per second.
func NewDeliveryQueue ¶
func NewDeliveryQueue(maxOperationsPerSecond int, deliveryFunc DeliveryFunc) (*DeliveryQueue, error)
func (*DeliveryQueue) Add ¶
func (q *DeliveryQueue) Add(item interface{})
Add adds an item to the queue
func (*DeliveryQueue) Poll ¶
func (q *DeliveryQueue) Poll()
Poll is processing items in the queue and delivers them. The function is blocking until StopPolling is called
func (*DeliveryQueue) StopPolling ¶
func (q *DeliveryQueue) StopPolling()
StopPolling stops execution of Poll and unblocks the goroutine
Click to show internal directories.
Click to hide internal directories.