memory

package
v0.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory is an in-process queue backend. It is intended for tests and single-process applications that need queue semantics without persistent infrastructure.

Delivery semantics: at-least-once (a handler that panics or returns an error causes redelivery). Ordering: FIFO per topic. Concurrency: competing consumers on the same topic split the message stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// MaxRetries caps redelivery attempts before a message is dropped.
	// Zero means unlimited (retry forever). Callers that need dead-letter
	// routing should use the hex/queue/jobs layer.
	MaxRetries int

	// RetryDelay is the wait between redeliveries of the same message.
	// Zero means immediate.
	RetryDelay time.Duration

	// PollInterval controls how often the background scheduler looks for
	// due delayed messages. Defaults to 50ms.
	PollInterval time.Duration
}

Options configures a memory Queue.

type Queue

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

Queue is an in-memory queue.Queue implementation.

func New

func New(opts Options) *Queue

New returns an empty in-memory queue.

func (*Queue) Close

func (q *Queue) Close(ctx context.Context) error

Close stops all consumers and drops any pending messages.

func (*Queue) PendingCount

func (q *Queue) PendingCount() int

PendingCount returns the number of ready messages across all topics. Useful for tests; not part of the queue.Queue interface.

func (*Queue) Publish

func (q *Queue) Publish(ctx context.Context, topicName string, body []byte, opts ...queue.PublishOptions) (string, error)

Publish adds body to topic.

func (*Queue) Subscribe

func (q *Queue) Subscribe(ctx context.Context, topicName string, handler queue.Handler) (queue.Subscription, error)

Subscribe attaches a handler to a topic. Multiple subscribers compete for messages (each message is delivered to exactly one).

Jump to

Keyboard shortcuts

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