pubsub

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

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

PubSub provides publish/subscribe functionality for real-time updates

func NewPubSub

func NewPubSub() *PubSub

NewPubSub creates a new PubSub instance

func (*PubSub) GetSubscriberCount

func (ps *PubSub) GetSubscriberCount(topic string) int

GetSubscriberCount returns the number of subscribers for a topic

func (*PubSub) Publish

func (ps *PubSub) Publish(topic string, message any)

Publish sends a message to all subscribers of a topic. Uses a snapshot copy to avoid holding lock during potentially slow channel sends.

func (*PubSub) Shutdown

func (ps *PubSub) Shutdown()

Shutdown closes all subscriptions and shuts down the PubSub

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(ctx context.Context, topic string) (*Subscription, error)

Subscribe creates a new subscription to a topic

type Subscription

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

Subscription represents a subscription to a topic

func (*Subscription) Channel

func (s *Subscription) Channel() <-chan any

Channel returns the subscription's message channel

func (*Subscription) Unsubscribe

func (s *Subscription) Unsubscribe()

Unsubscribe removes the subscription

Jump to

Keyboard shortcuts

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