memq

package
v0.0.0-...-2d28c6b Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPubSub

func NewPubSub[K comparable, E any](getKey func(E) K, opts ...Option) queue.PubSub[K, E]

NewPubSub returns an in-memory implementation of the Publish–Subscribe pattern.

The getKey function extracts a routing key from messages to determine which subscribers receive them.

Example:

pb := NewPubSub(func(msg *MyMessage) string { return msg.Topic })
go pb.Start(ctx)
pb.Pub(ctx, &MyMessage{Topic: "news", Content: "Hello"})

Types

type Option

type Option func(o *newOption)

func WithLogger

func WithLogger(log *slog.Logger) Option

WithLogger sets the logger.

func WithPubCapacity

func WithPubCapacity(capacity uint) Option

WithPubCapacity sets the capacity of the publisher channel. Larger values allow more messages to be buffered before blocking publishers.

func WithSubCapacity

func WithSubCapacity(capacity uint) Option

WithSubCapacity sets the capacity of each subscriber channel. Larger values allow more messages to be buffered per subscriber before dropping messages.

Jump to

Keyboard shortcuts

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