memory

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package memory is the in-process fanout.Bus: every Bus made from one Hub delivers to every subscriber of that Hub. One Hub stands for one backend, so a test can run two replicas in one process; a deployment with one replica uses one Hub and one Bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus is one replica's view of a Hub.

func New

func New() *Bus

New returns a Bus over its own Hub, for a deployment of one replica.

func (*Bus) Close

func (b *Bus) Close() error

Close ends every subscription made through this Bus.

func (*Bus) Publish

func (b *Bus) Publish(ctx context.Context, topic string, data []byte) error

Publish delivers data to every current subscriber of topic without waiting for any of them.

func (*Bus) Subscribe

func (b *Bus) Subscribe(ctx context.Context, topic string) (fanout.Subscription, error)

Subscribe registers a subscriber on topic until ctx ends or it is closed.

type Hub

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

Hub is the shared backend: what a database or a broker is to the other adapters.

func NewHub

func NewHub() *Hub

NewHub returns a Hub with no subscribers.

func (*Hub) Bus

func (h *Hub) Bus() *Bus

Bus returns a new Bus over h.

Jump to

Keyboard shortcuts

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