pubsub

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

func NewBroker

func NewBroker[T any]() *Broker[T]

func (*Broker[T]) GetSubscriberCount

func (b *Broker[T]) GetSubscriberCount() int

func (*Broker[T]) Publish

func (b *Broker[T]) Publish(eventType EventType, payload T)

func (*Broker[T]) Shutdown

func (b *Broker[T]) Shutdown()

func (*Broker[T]) Subscribe

func (b *Broker[T]) Subscribe(ctx context.Context) <-chan Event[T]

type Event

type Event[T any] struct {
	Type    EventType
	Payload T
}

type EventType

type EventType string
const (
	EventTypeCreated EventType = "created"
	EventTypeUpdated EventType = "updated"
	EventTypeDeleted EventType = "deleted"
)

type Publisher

type Publisher[T any] interface {
	Publish(eventType EventType, payload T)
}

type Subscriber

type Subscriber[T any] interface {
	Subscribe(ctx context.Context) <-chan Event[T]
}

Jump to

Keyboard shortcuts

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