pubsub

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Topic

type Topic[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() *Topic[T]

New creates a new topic that can be used to publish and subscribe to messages.

func (*Topic[T]) Close

func (s *Topic[T]) Close() error

Close the topic, blocking until all subscribers have been closed.

func (*Topic[T]) Publish

func (s *Topic[T]) Publish(t T)

func (*Topic[T]) Subscribe

func (s *Topic[T]) Subscribe(c chan T) chan T

Subscribe a channel to the topic.

The channel will be closed when the topic is closed.

func (*Topic[T]) Unsubscribe

func (s *Topic[T]) Unsubscribe(c chan T)

Unsubscribe a channel from the topic, closing the channel.

Jump to

Keyboard shortcuts

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