eventstream

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventsStream

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

EventsStream defines the stream broker

func New

func New() *EventsStream

New creates an instance of EventsStream

func (*EventsStream) AddSubscriber

func (b *EventsStream) AddSubscriber() Subscriber

AddSubscriber adds a subscriber

func (*EventsStream) Broadcast

func (b *EventsStream) Broadcast(msg any, topics []string)

Broadcast notifies all subscribers of a given topic of a new message

func (*EventsStream) Publish

func (b *EventsStream) Publish(topic string, msg any)

Publish publishes a message to a topic

func (*EventsStream) RemoveSubscriber

func (b *EventsStream) RemoveSubscriber(sub Subscriber)

RemoveSubscriber removes a subscriber

func (*EventsStream) Shutdown

func (b *EventsStream) Shutdown()

Shutdown shutdowns the broker

func (*EventsStream) Subscribe

func (b *EventsStream) Subscribe(sub Subscriber, topic string)

Subscribe subscribes a subscriber to a topic

func (*EventsStream) SubscribersCount

func (b *EventsStream) SubscribersCount(topic string) int

SubscribersCount returns the number of subscribers for a given topic

func (*EventsStream) Unsubscribe

func (b *EventsStream) Unsubscribe(sub Subscriber, topic string)

Unsubscribe removes a subscriber from a topic

type Message

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

Message defines the stream message

func NewMessage

func NewMessage(topic string, payload any) *Message

NewMessage creates an instance of Stream Message

func (Message) Payload

func (m Message) Payload() any

Payload returns the message payload

func (Message) Topic

func (m Message) Topic() string

Topic returns the message topic

type Subscriber

type Subscriber interface {
	Topics() []string
	Iterator() chan *Message
	Shutdown()

	Active() bool
	ID() string
	// contains filtered or unexported methods
}

Subscriber defines the Subscriber Interface

type Subscribers

type Subscribers map[string]Subscriber

Subscribers defines the map of subscribers

Jump to

Keyboard shortcuts

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