dispatcher

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dispatcher provides event dispatching with persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventDispatcher

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

EventDispatcher dispatches events to the bus and optionally persists them.

func NewDispatcher

func NewDispatcher(b *bus.EventBus, opts ...Option) *EventDispatcher

NewDispatcher creates a new EventDispatcher.

func (*EventDispatcher) Close

func (d *EventDispatcher) Close()

Close gracefully shuts down the dispatcher.

func (*EventDispatcher) Dispatch

func (d *EventDispatcher) Dispatch(ctx context.Context, event bus.Event) error

Dispatch publishes an event to subscribers and persists it if configured.

func (*EventDispatcher) DispatchAsync

func (d *EventDispatcher) DispatchAsync(ctx context.Context, event bus.Event)

DispatchAsync publishes an event asynchronously without blocking.

func (*EventDispatcher) Subscribe

func (d *EventDispatcher) Subscribe(eventType bus.EventType, subscriber bus.Subscriber)

Subscribe adds a subscriber for the given event type.

func (*EventDispatcher) Unsubscribe

func (d *EventDispatcher) Unsubscribe(eventType bus.EventType, subscriber bus.Subscriber)

Unsubscribe removes a subscriber for the given event type.

type Option

type Option func(*EventDispatcher)

Option configures the EventDispatcher.

func WithLogger

func WithLogger(logger bus.Logger) Option

WithLogger sets the logger for the dispatcher.

func WithRepository

func WithRepository(repo repository.EventRepository) Option

WithRepository enables event persistence.

Jump to

Keyboard shortcuts

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