eventbus

package
v0.0.0-...-0145ae5 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CONSUMER_BUFFER_SIZE = 10

Variables

View Source
var ErrChannelClosed = errors.New("channel closed")

Functions

func Merge

func Merge[T any](ctx context.Context, chs []<-chan T) (T, error)

func NewRateLimiter

func NewRateLimiter() workqueue.RateLimiter

func SubscriberMatch

func SubscriberMatch(subs Subscribers, topic string) ([]chan events.Event, bool)

SubscriberMatch match all the subscribers to the topic name

Types

type Consumer

type Consumer interface {
	Id() string
	OnEventSync(ctx context.Context) events.Event
	OnEvent() <-chan events.Event
	UnSubscribe() error
}

func MergeConsumers

func MergeConsumers(consumers ...Consumer) Consumer

func NewConsumer

func NewConsumer(bus *EventBus, topic string, consumerCh chan events.Event) Consumer

type EventBus

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

func NewEventBus

func NewEventBus(workers int) *EventBus

NewEventBus creates a new EventBus that uses multiple workers to publish events to any subscribers

func (*EventBus) Publish

func (d *EventBus) Publish(topic string, event events.Event) error

Publish queue an event to a topic

func (*EventBus) Start

func (d *EventBus) Start(ctx context.Context) error

Start implements the Runnable interface so that it can be started by the Operator SDK manager.

func (*EventBus) Subscribe

func (d *EventBus) Subscribe(topic string) (Consumer, error)

Subscribe registers a subscription on the topic

type EventConsumer

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

func (EventConsumer) Id

func (c EventConsumer) Id() string

func (EventConsumer) OnEvent

func (c EventConsumer) OnEvent() <-chan events.Event

func (EventConsumer) OnEventSync

func (c EventConsumer) OnEventSync(ctx context.Context) events.Event

func (EventConsumer) UnSubscribe

func (c EventConsumer) UnSubscribe() error

type EventConsumerSet

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

func (EventConsumerSet) Id

func (c EventConsumerSet) Id() string

func (EventConsumerSet) OnEvent

func (cs EventConsumerSet) OnEvent() <-chan events.Event

func (EventConsumerSet) OnEventSync

func (cs EventConsumerSet) OnEventSync(ctx context.Context) events.Event

func (EventConsumerSet) UnSubscribe

func (cs EventConsumerSet) UnSubscribe() error

type Subscribers

type Subscribers map[string][]chan events.Event

Jump to

Keyboard shortcuts

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