bus

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package bus is a lightweight publish-subscribe message bus. It decouples components by letting them communicate through typed topics instead of direct method calls. Thread-safe; zero allocations on the publish path when there are no subscribers for a topic.

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
}

func New

func New() *Bus

func (*Bus) Pub

func (b *Bus) Pub(topic string, msg Msg)

func (*Bus) Sub

func (b *Bus) Sub(topic string, fn Handler) (stop func())

func (*Bus) SubscriberCount

func (b *Bus) SubscriberCount() int

func (*Bus) Topics

func (b *Bus) Topics() []string

type Handler

type Handler func(topic string, msg Msg)

type Msg

type Msg = any

Jump to

Keyboard shortcuts

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