pubsub

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler[T any] func(T) error

type PubSub

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

func NewPubSub

func NewPubSub[T any]() *PubSub[T]

func (*PubSub[T]) Publish

func (ps *PubSub[T]) Publish(msg T)

func (*PubSub[T]) Subscribe

func (ps *PubSub[T]) Subscribe(onMsg MessageHandler[T]) *Subscription[T]

func (*PubSub[T]) Unsubscribe

func (ps *PubSub[T]) Unsubscribe(sub *Subscription[T])

type Subscription

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

func NewSubscription

func NewSubscription[T any](onMsg MessageHandler[T]) *Subscription[T]

func (*Subscription[T]) GetID

func (s *Subscription[T]) GetID() string

func (*Subscription[T]) Push

func (s *Subscription[T]) Push(msg T)

func (*Subscription[T]) Run

func (s *Subscription[T]) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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