pubsub

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

A generic pubsub system built with go channels. Used to communicate different pieces of data across the app. Latest block, stream txs, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pubsub

type Pubsub[Message any] struct {
	// contains filtered or unexported fields
}

func NewPubsub

func NewPubsub[Message any]() *Pubsub[Message]

func (*Pubsub[Message]) Publish

func (ps *Pubsub[Message]) Publish(ctx context.Context, topic string, msg Message)

Publish sends a message to all subscribers of the specified topic

func (*Pubsub[Message]) Subscribe

func (ps *Pubsub[Message]) Subscribe(topic string, bufferSizes ...int) chan Message

Subscribe subscribes to a specific topic and returns a channel to receive messages.

func (*Pubsub[Message]) Unsubscribe

func (ps *Pubsub[Message]) Unsubscribe(topic string, ch chan Message)

Unsubscribe removes a subscriber from a topic and closes the channel.

Jump to

Keyboard shortcuts

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