Documentation
¶
Overview ¶
Package dispatcher provides event dispatching with persistence.
Index ¶
- type EventDispatcher
- func (d *EventDispatcher) Close()
- func (d *EventDispatcher) Dispatch(ctx context.Context, event bus.Event) error
- func (d *EventDispatcher) DispatchAsync(ctx context.Context, event bus.Event)
- func (d *EventDispatcher) Subscribe(eventType bus.EventType, subscriber bus.Subscriber)
- func (d *EventDispatcher) Unsubscribe(eventType bus.EventType, subscriber bus.Subscriber)
- type Option
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 ¶
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 ¶
WithLogger sets the logger for the dispatcher.
func WithRepository ¶
func WithRepository(repo repository.EventRepository) Option
WithRepository enables event persistence.
Click to show internal directories.
Click to hide internal directories.