bytequeue

package
v0.0.0-...-32c7374 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue interface {
	// Closed returns true if the queue is closed.
	Closed() bool

	// Clear releases all unread messages.
	Clear()

	// Close closes the queue for writing, it is still possible to read pending messages.
	Close()

	// Read reads an message from the queue, the message is valid until the next call to read.
	// The method returns an end status when there are no more items and the queue is closed.
	Read() ([]byte, bool, status.Status)

	// ReadWait returns a channel which is notified when more messages are available.
	// The method returns a closed channel if the queue is closed.
	ReadWait() <-chan struct{}

	// Write writes an message to the queue, returns false if full, or an end if closed.
	Write(msg []byte) (bool, status.Status)

	// WriteWait returns a channel which is notified when a message can be written.
	// The method returns a closed channel if the queue is closed.
	WriteWait(size int) <-chan struct{}

	// Reset resets the queue, releases all unread messages, the queue can be used again.
	Reset()

	// Free releases the queue and its internal resources.
	Free()
}

Queue is a single reader multiple writers binary message queue.

The queue can be unbounded, or can be configured with a soft max capacity. Writes mostly do not block readers.

func New

func New() Queue

New allocates an unbounded byte queue.

func NewCap

func NewCap(cap int) Queue

NewCap allocates a byte queue with a soft max capacity.

Jump to

Keyboard shortcuts

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