Documentation
¶
Index ¶
- Variables
- type MessageQueue
- type Option
- type PubSub
- type Queue
- func (q *Queue[T]) Close() error
- func (q *Queue[T]) Consume(ctx context.Context, topic string) (T, error)
- func (q *Queue[T]) Publish(ctx context.Context, topic string, data T) error
- func (q *Queue[T]) PurgeQueue(ctx context.Context, topic string) error
- func (q *Queue[T]) TryConsume(ctx context.Context, topic string) (T, bool, error)
- type Subscription
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoMessage = errors.New("memory mq: no message available") ErrQueueClosed = errors.New("memory mq: queue is closed") )
Functions ¶
This section is empty.
Types ¶
type MessageQueue ¶
MessageQueue combines both queue and publish-subscribe functionality in a single memory-based implementation. It provides both point-to-point messaging and broadcast messaging capabilities.
func NewMessageQueue ¶
func NewMessageQueue[T any](opt ...Option) *MessageQueue[T]
NewMessageQueue creates a new memory-based message queue that supports both queue and pub/sub operations. The same options apply to both the underlying queue and pub/sub components.
func (*MessageQueue[T]) Close ¶
func (p *MessageQueue[T]) Close() error
type Option ¶
type Option func(*options)
Option defines a function type for configuring memory message queue options.
func WithQueueSize ¶
WithQueueSize sets the buffer size for message channels in the memory queue. A larger size allows more messages to be buffered before blocking publishers.
type PubSub ¶
type PubSub[T any] struct { // contains filtered or unexported fields }
PubSub implements an in-memory publish-subscribe message system with typed message support. It broadcasts messages to all active subscribers of a topic.
func NewPubSub ¶
NewPubSub creates a new memory-based publish-subscribe system with the specified options. The default queue size is 100 messages per subscription.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue implements an in-memory point-to-point message queue with typed message support. It provides FIFO message delivery to exactly one consumer per topic.
func NewQueue ¶
NewQueue creates a new memory-based queue with the specified options. The default queue size is 100 messages per topic.
func (*Queue[T]) PurgeQueue ¶
type Subscription ¶
type Subscription[T any] struct { // contains filtered or unexported fields }
Subscription represents an active subscription to a topic with its associated handler and channels.