membus

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package membus provides an in-memory implementation of eventbus.EventBus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, opts ...Option) eventbus.EventBus

New returns a new in-memory EventBus.

Types

type Bus

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

Bus is an in-memory implementation of EventBus.

func (*Bus) Publish

func (b *Bus) Publish(topic string, data any)

Publish sends a message to all subscribers.

func (*Bus) Shutdown

func (b *Bus) Shutdown(ctx context.Context) error

Shutdown closes the job channel and waits for all workers to finish.

func (*Bus) Subscribe

func (b *Bus) Subscribe(topic string, handler eventbus.Handler)

Subscribe registers a handler for broadcast messages.

func (*Bus) Wait

func (b *Bus) Wait(ctx context.Context) error

Wait blocks until all pending messages are processed.

type Option

type Option func(*Bus)

Option configures the bus.

func WithWorkerPool

func WithWorkerPool(size int) Option

WithWorkerPool sets the number of worker goroutines for processing events. Default is 100 workers. Set to 0 to use unbounded goroutines.

Jump to

Keyboard shortcuts

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