queue

package
v0.0.0-...-6f75e30 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OffsetNotFoundError = queueEB(errors.New("offset not found"))
	IsEmpty             = queueEB(errors.New("queue is empty"))
)

Functions

This section is empty.

Types

type Queue

type Queue[Element any] struct {
	// contains filtered or unexported fields
}

Queue - sized queue. All public operations:

- GetAll - GetByOffset - Append

execs synchronously using sync.RWMutex to prevent race condition.

func NewQueue

func NewQueue[Element any](configuration configuration.Queue) *Queue[Element]

NewQueue - Queue constructor.

func (*Queue[Element]) Append

func (q *Queue[Element]) Append(element Element) uint64

Append - put an element to the queues tail and delete oldest

func (*Queue[Element]) GetAll

func (q *Queue[Element]) GetAll() []Element

GetAll - return all queued elements.

func (*Queue[Element]) GetByOffset

func (q *Queue[Element]) GetByOffset(offset uint64) (Element, uint64, error)

GetByOffset - return an element by its offset. If the offset too old and not represent at the queue returns the oldest element and its offset. If the offset gte q.max returns error and last element offset.

func (*Queue[Element]) GetLast

func (q *Queue[Element]) GetLast() (Element, uint64, error)

GetLast - returns the last element or error if queue is empty

Jump to

Keyboard shortcuts

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