queue

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInitialized = errors.New("queue: not initialized, call Init first")
	ErrUnknownBackend = errors.New("queue: unknown backend")
)

Functions

func Close

func Close() error

Close stops the polling loop and waits for it to finish.

func Init

func Init(ctx context.Context, b string, d *sql.DB) error

Init initializes the queue with the given backend ("postgres" or "memory"). For "postgres", db must be non-nil; the fullend_queue table is auto-created.

func Publish

func Publish(ctx context.Context, topic string, payload any, opts ...PublishOption) error

Publish sends a message to the given topic.

func Start

func Start(ctx context.Context) error

Start begins processing queued messages. It blocks until the context is cancelled. For the memory backend this is a no-op that blocks until cancel.

func Subscribe

func Subscribe(topic string, handler func(ctx context.Context, msg []byte) error)

Subscribe registers a handler for the given topic.

Types

type PublishOption

type PublishOption func(*publishConfig)

PublishOption configures a Publish call.

func WithDelay

func WithDelay(seconds int) PublishOption

WithDelay sets the delivery delay in seconds.

func WithPriority

func WithPriority(p string) PublishOption

WithPriority sets the message priority ("high", "normal", "low").

Jump to

Keyboard shortcuts

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