chanpubsub

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package chanpubsub provides an in-process PubSub implementation backed by Go channels. It supports dot-separated topics with wildcards (* = one segment, > = rest). Ideal for development and testing — zero external deps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanPubSub

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

ChanPubSub is an in-process fan-out pub/sub with wildcard topic matching.

func New

func New() *ChanPubSub

New creates a new in-process PubSub.

func (*ChanPubSub) Close

func (c *ChanPubSub) Close() error

Close removes all subscriptions.

func (*ChanPubSub) Publish

func (c *ChanPubSub) Publish(topic string, data []byte) error

Publish sends data to all subscribers whose pattern matches the topic. Handlers are called in separate goroutines.

func (*ChanPubSub) Subscribe

func (c *ChanPubSub) Subscribe(topic string, handler func([]byte)) (pubsub.Subscription, error)

Subscribe registers a handler for topics matching the given pattern.

Jump to

Keyboard shortcuts

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