Documentation
¶
Overview ¶
Package mediator provides the legacy in-process mediator.
Deprecated: use github.com/go-jimu/components/ddd/event for new domain event code. Package mediator is kept for backward compatibility and will only receive compatibility fixes.
Index ¶
- Variables
- func Dispatch(ev Event)deprecated
- func SetDefault(m Mediator)deprecated
- func Subscribe(hdl EventHandler)deprecated
- type Eventdeprecated
- type EventCollectiondeprecated
- type EventHandlerdeprecated
- type EventKinddeprecated
- type InMemMediatordeprecated
- func (m *InMemMediator) Dispatch(ev Event) error
- func (m *InMemMediator) GracefulShutdown(ctx context.Context) error
- func (m *InMemMediator) Subscribe(hdl EventHandler)
- func (m *InMemMediator) WithDelayClose(d time.Duration)deprecated
- func (m *InMemMediator) WithGenContext(fn func(ctx context.Context, ev Event) context.Context)deprecated
- func (m *InMemMediator) WithLogger(logger *slog.Logger)deprecated
- func (m *InMemMediator) WithOrphanEventHandler(fn func(Event) error)deprecated
- func (m *InMemMediator) WithTimeout(timeout time.Duration)deprecated
- type Mediatordeprecated
- func Default() Mediatordeprecated
- func NewInMemMediator(opt Options, opts ...Option) Mediatordeprecated
- type Optiondeprecated
- func WithDelayClose(d time.Duration) Optiondeprecated
- func WithGenContext(fn func(ctx context.Context, ev Event) context.Context) Optiondeprecated
- func WithLogger(logger *slog.Logger) Optiondeprecated
- func WithOrphanEventHandler(fn func(Event) error) Optiondeprecated
- func WithTimeout(timeout time.Duration) Optiondeprecated
- type Optionsdeprecated
Constants ¶
This section is empty.
Variables ¶
var ( // Deprecated: use github.com/go-jimu/components/ddd/event.Dispatcher return // values for new domain event code. ErrMediatorClosed = errors.New("mediator is closed") // Deprecated: use github.com/go-jimu/components/ddd/event.WithUnhandledEventHandler // for new domain event code. ErrNoHandlerMatched = errors.New("no matching event handler found") )
Functions ¶
func SetDefault
deprecated
func SetDefault(m Mediator)
SetDefault sets the default global mediator.
Deprecated: use explicit github.com/go-jimu/components/ddd/event.Dispatcher instances for new domain event code.
func Subscribe
deprecated
func Subscribe(hdl EventHandler)
Deprecated: use explicit github.com/go-jimu/components/ddd/event.Dispatcher instances for new domain event code.
Types ¶
type EventCollection
deprecated
Deprecated: use github.com/go-jimu/components/ddd/event.Collection for new domain event code.
func NewEventCollection
deprecated
func NewEventCollection() EventCollection
Deprecated: use github.com/go-jimu/components/ddd/event.NewCollection for new domain event code.
type EventHandler
deprecated
type InMemMediator
deprecated
type InMemMediator struct {
// contains filtered or unexported fields
}
InMemMediator is a simple in-memory mediator implementation.
Deprecated: use github.com/go-jimu/components/ddd/event.NewDispatcher for new domain event code.
func (*InMemMediator) Dispatch ¶
func (m *InMemMediator) Dispatch(ev Event) error
Dispatch dispatches an event to the mediator.
func (*InMemMediator) GracefulShutdown ¶ added in v0.6.3
func (m *InMemMediator) GracefulShutdown(ctx context.Context) error
GracefulShutdown waits for all the events to be processed and then closes the mediator. The caller controls the maximum wait time via ctx.
func (*InMemMediator) Subscribe ¶
func (m *InMemMediator) Subscribe(hdl EventHandler)
Subscribe registers an event handler to the mediator.
func (*InMemMediator) WithDelayClose
deprecated
added in
v0.7.2
func (m *InMemMediator) WithDelayClose(d time.Duration)
Deprecated: Use WithDelayClose Option in NewInMemMediator instead.
func (*InMemMediator) WithGenContext
deprecated
added in
v0.5.11
func (*InMemMediator) WithLogger
deprecated
added in
v0.6.1
func (m *InMemMediator) WithLogger(logger *slog.Logger)
Deprecated: Use WithLogger Option in NewInMemMediator instead.
func (*InMemMediator) WithOrphanEventHandler
deprecated
func (m *InMemMediator) WithOrphanEventHandler(fn func(Event) error)
Deprecated: Use WithOrphanEventHandler Option in NewInMemMediator instead.
func (*InMemMediator) WithTimeout
deprecated
added in
v0.5.11
func (m *InMemMediator) WithTimeout(timeout time.Duration)
Deprecated: Use WithTimeout Option in NewInMemMediator instead.
type Mediator
deprecated
type Mediator interface {
Dispatch(Event) error
Subscribe(EventHandler)
}
Mediator is the interface that wraps the methods of a mediator.
Deprecated: use github.com/go-jimu/components/ddd/event.Dispatcher for new domain event code.
func NewInMemMediator
deprecated
type Option
deprecated
added in
v0.1.1
type Option func(*InMemMediator)
Option configures an InMemMediator during construction.
Deprecated: use github.com/go-jimu/components/ddd/event options for new domain event code.