eventsfx

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEventTimeout = errors.New("event timeout")

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultBufferSize int           `conf:"DEFAULT_BUFFER_SIZE" default:"100"`
	ReplyTimeout      time.Duration `conf:"REPLY_TIMEOUT"       default:"5s"`
}

type Event

type Event struct {
	Data      any
	ReplyChan chan any
	Name      string
}

type EventBus

type EventBus struct {
	InnerMetrics *Metrics

	Subscribers map[string][]EventHandler
	Queue       chan Event

	Config *Config
	// contains filtered or unexported fields
}

func NewEventBus

func NewEventBus(
	config *Config,
	metricsProvider MetricsProvider,
	logger *slog.Logger,
) *EventBus

func (*EventBus) Cleanup

func (bus *EventBus) Cleanup()

func (*EventBus) Dispatch

func (bus *EventBus) Dispatch(event Event)

func (*EventBus) DispatchSync

func (bus *EventBus) DispatchSync(event Event)

func (*EventBus) Listen

func (bus *EventBus) Listen()

func (*EventBus) Publish

func (bus *EventBus) Publish(event Event)

func (*EventBus) PublishSync

func (bus *EventBus) PublishSync(event Event) (any, error)

func (*EventBus) Subscribe

func (bus *EventBus) Subscribe(eventName string, handler EventHandler)

type EventHandler

type EventHandler func(event Event)

type Metrics

type Metrics struct {
	RequestsTotal *prometheus.CounterVec
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(mp MetricsProvider) *Metrics

type MetricsProvider

type MetricsProvider interface {
	GetRegistry() *prometheus.Registry
}

Jump to

Keyboard shortcuts

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