dispatcher

package
v0.0.0-...-1333b54 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) AddEventProviders

func (d *Dispatcher) AddEventProviders(providers ...<-chan event.Event)

AddEventProviders registers provided channels as an event source. Events from these providers will be parsed by the subscribed handlers

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(e event.Event)

func (*Dispatcher) Register

func (d *Dispatcher) Register(h ...Listener)

Register is a helper method allowing to subscribe multiple event listeners at once.

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context)

Run blocks until the context is cancelled. Run starts the dispatcher to listen for events from its event providers and dispatch those events.

func (*Dispatcher) Subscribe

func (d *Dispatcher) Subscribe(eType event.EventType, handlers ...event.Handler)

Subscribe registers handlers for specified event type. They will be invoked when an according event is dispatched.

type Listener

type Listener interface {
	// EventHandlers returns all event handlers specific to an implementation
	// which are registered at the composition root.
	// These handlers should not be used to sync read and write models
	// and should be separated from them, applying other domain events.
	EventHandlers() map[event.EventType][]event.Handler
}

Jump to

Keyboard shortcuts

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