priorityq

package
v0.2.2-pipeline-release.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// High indicates the highest priority
	High = Priority(0)

	// Mid indicates the medium priority
	Mid = Priority(1)

	// Low indicates the lowest priority
	Low = Priority(2)
)

Variables

View Source
var (
	// ErrUnknownPriority indicates an incorrect attempt to make a write with an unknown priority
	ErrUnknownPriority = errors.New("unknown priority")

	// ErrQueueClosed indicates an attempt to read from a closed priority queue instance
	ErrQueueClosed = errors.New("the queue is closed")

	// ErrUnexpected indicates an unexpected error attempting to read from the queue
	ErrUnexpected = errors.New("unexpected error reading from queues")
)

Functions

This section is empty.

Types

type Priority

type Priority int

Priority is the type that indicates the priority of different queues

type PriorityQueue added in v0.1.31

type PriorityQueue interface {
	Write(prio Priority, m interface{}) error
	Read() (interface{}, error)
	Close()
	Length() int
}

PriorityQueue is the interface used to interact with the queue

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is the priority queue

func New

func New(prioQueueLimit int) *Queue

New returns a new priority queue where each priority has a buffer of prioQueueLimit

func (*Queue) Close

func (pq *Queue) Close()

Close the priority queue No messages should be expected to be read after a call to Close

func (*Queue) Length added in v0.1.33

func (pq *Queue) Length() (length int)

Length returns the number of pending messages in all of the queues

func (*Queue) Read

func (pq *Queue) Read() (interface{}, error)

Read returns the next message by priority An error is returned iff the priority queue has been closed

func (*Queue) Write

func (pq *Queue) Write(prio Priority, m interface{}) error

Write a message m to the associated queue with the provided priority This method blocks iff the queue is full Returns an error iff a queue does not exist for the provided name Note: writing to the pq after a call to close is forbidden and will result in a panic

Jump to

Keyboard shortcuts

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