pubsub

package
v1.5.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MsgHoldDuration = time.Second * 10
)

Variables

View Source
var DefaultCachedPubSub = NewRegistry()

Functions

func Publish

func Publish(topicName string, msg Message)

Publish sends a message to the specified topic. If the topic does not exist, the message is silently dropped.

Types

type Broadcaster

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

func NewBroadcaster

func NewBroadcaster() *Broadcaster

func (*Broadcaster) Broadcast

func (b *Broadcaster) Broadcast(msg Message)

func (*Broadcaster) GetListener

func (b *Broadcaster) GetListener() *Listener

GetListener Message subscribers obtain message listener from the broadcaster to receive broadcasts. The listener is similar to a radio.

type Broker

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

type CachedPubSub

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

func NewRegistry

func NewRegistry() *CachedPubSub

func (*CachedPubSub) Publish

func (r *CachedPubSub) Publish(topicName string, msg Message)

func (*CachedPubSub) Subscribe

func (r *CachedPubSub) Subscribe(topicName string, ctx context.Context, handler Handler) error

type Handler

type Handler func(msg Message)

type Listener

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

func NewListener

func NewListener() *Listener

func Subscribe

func Subscribe(topicName string) *Listener

Subscribe Return a message listener for receiving broadcast messages

func (*Listener) Listen

func (l *Listener) Listen(ctx context.Context, handle func(msg Message)) *Listener

func (*Listener) Publish

func (l *Listener) Publish(msg Message) *Listener

type Message

type Message interface {
	Ref()
	UnRef()
	UniqueId() uint64
}

Jump to

Keyboard shortcuts

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