pqueue

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pqueue implements persistent queues.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmpty = errors.New("empty queue")

Functions

This section is empty.

Types

type PQueue

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

PQueue represents a persistent FIFO queue.

func New

func New(db *bolt.DB, name string) (*PQueue, error)

New returns a new PQueue instance with the given name. When a queue with that name already exists in the DB, it will be re-used.

func (*PQueue) Clear

func (q *PQueue) Clear() error

Clear deletes all items from the queue.

func (*PQueue) Get

func (q *PQueue) Get() ([]byte, error)

Get returns an item from the queue. If the queue is empty it will block until there is a new item in the queue.

func (*PQueue) GetNoWait

func (q *PQueue) GetNoWait() ([]byte, error)

GetNoWait return an item from the queue. When the queue is empty it returns the ErrEmpty error.

func (*PQueue) GetWithContext

func (q *PQueue) GetWithContext(ctx context.Context) ([]byte, error)

GetWithContext returns an item from the queue. If the queue is empty it will block until there is a new item in the queue or the context is canceled.

func (*PQueue) IsEmpty

func (q *PQueue) IsEmpty() bool

IsEmpty reports wether the queue is empty.

func (*PQueue) Put

func (q *PQueue) Put(v []byte) error

Puts adds an item to the queue.

func (*PQueue) Size

func (q *PQueue) Size() int

Jump to

Keyboard shortcuts

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