queue

package
v0.0.0-...-58614dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 4 Imported by: 0

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

Directories

Path Synopsis
Spin provides objects for assisting with sleeping while waiting for an action to become available.
Spin provides objects for assisting with sleeping while waiting for an action to become available.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL