pubsub

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Subject  string            `json:"subject"`            // The exact subject name
	Data     interface{}       `json:"data"`               // The actual event data
	Metadata map[string]string `json:"metadata,omitempty"` // Optional metadata like timestamps, IDs, etc.
}

type EventDispatcher

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

func NewEventDispatcher

func NewEventDispatcher(ctx context.Context) *EventDispatcher

NewEventDispatcher creates a new EventDispatcher with a dedicated goroutine for processing.

func (*EventDispatcher) Publish

func (ed *EventDispatcher) Publish(subject string, data interface{})

Publish sends a message to all subscribers of the given subject.

func (*EventDispatcher) Subscribe

func (ed *EventDispatcher) Subscribe(subject string) (<-chan Event, func())

Jump to

Keyboard shortcuts

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