memory

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package memory provides an in-process messaging backend for no-infra builds and tests.

A Broker holds one buffered channel per topic; a Publisher and Subscriber connect only when handed the SAME broker instance (not package-global state), so two separate brokers are fully isolated. Mirrors the Python messaging/memory backend. Selected by the messaging tier Kind (D7).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker is an in-process message broker: a lazily-created buffered channel per topic.

func NewBroker

func NewBroker() *Broker

NewBroker creates an empty in-process broker.

type Publisher

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

Publisher enqueues messages onto a Broker instead of SQS (dev/test; no external broker).

func NewPublisher

func NewPublisher(broker *Broker) *Publisher

NewPublisher publishes onto broker; a Subscriber built from the same broker receives the messages.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, topic string, payload []byte) error

Publish enqueues payload on topic as a Message, or returns ctx's error if it is cancelled first.

func (*Publisher) PublishBatch

func (p *Publisher) PublishBatch(
	ctx context.Context,
	topic string,
	payloads [][]byte,
) error

PublishBatch enqueues each payload on topic in order.

type Subscriber

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

Subscriber consumes messages from a Broker instead of SQS (dev/test; no external broker).

func NewSubscriber

func NewSubscriber(broker *Broker) *Subscriber

NewSubscriber consumes from broker; a Publisher built from the same broker feeds this subscriber.

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close stops the receive loop (idempotent).

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(
	ctx context.Context,
	topic string,
	handler interfaces.MessageHandler,
) error

Subscribe delivers each message on topic to handler until Close is called or ctx is cancelled. A handler error is dropped: the in-memory broker has no redelivery, so this is a stub's best effort — good enough to exercise the consume path with no SQS, not to model at-least-once.

Jump to

Keyboard shortcuts

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