Documentation ¶
Overview ¶
Package engine contains an in-memory Dogma engine.
Index ¶
- type Engine
- func (e *Engine) Dispatch(ctx context.Context, m dogma.Message, options ...OperationOption) error
- func (e *Engine) ExecuteCommand(ctx context.Context, m dogma.Message) error
- func (e *Engine) RecordEvent(ctx context.Context, m dogma.Message) error
- func (e *Engine) Reset()
- func (e *Engine) Tick(ctx context.Context, options ...OperationOption) error
- type OperationOption
- func EnableAggregates(enabled bool) OperationOption
- func EnableIntegrations(enabled bool) OperationOption
- func EnableProcesses(enabled bool) OperationOption
- func EnableProjections(enabled bool) OperationOption
- func WithCurrentTime(t time.Time) OperationOption
- func WithObserver(o fact.Observer) OperationOption
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is an in-memory Dogma engine that is used to execute tests.
func New ¶
func New(app dogma.Application, options ...Option) (*Engine, error)
New returns a new engine that uses the given app configuration.
func (*Engine) Dispatch ¶
func (e *Engine) Dispatch( ctx context.Context, m dogma.Message, options ...OperationOption, ) error
Dispatch processes a message.
It is not an error to process a message that is not routed to any handlers.
func (*Engine) ExecuteCommand ¶
ExecuteCommand enqueues a command for execution. It panics if the command is not routed to any handlers.
func (*Engine) RecordEvent ¶
RecordEvent records the occurrence of an event. It is not an error to record an event that is not routed to any handlers.
type OperationOption ¶
type OperationOption func(*operationOptions)
OperationOption applies optional settings while dispatching a message or performing a tick.
func EnableAggregates ¶
func EnableAggregates(enabled bool) OperationOption
EnableAggregates returns a dispatch option that enables or disables aggregate message handlers.
All handler types are enabled by default.
func EnableIntegrations ¶
func EnableIntegrations(enabled bool) OperationOption
EnableIntegrations returns a dispatch option that enables or disables integration message handlers.
All handler types are enabled by default.
func EnableProcesses ¶
func EnableProcesses(enabled bool) OperationOption
EnableProcesses returns a dispatch option that enables or disables process message handlers.
All handler types are enabled by default.
func EnableProjections ¶
func EnableProjections(enabled bool) OperationOption
EnableProjections returns a dispatch option that enables or disables projection message handlers.
All handler types are enabled by default.
func WithCurrentTime ¶
func WithCurrentTime(t time.Time) OperationOption
WithCurrentTime returns a dispatch option that sets the engine's current time.
func WithObserver ¶
func WithObserver(o fact.Observer) OperationOption
WithObserver returns an option that registers the given observer for the duration of the operation.
Multiple observers can be registered during a single operation.
type Option ¶
type Option func(*engineOptions)
Option applies optional engine-wide settings.
func WithResetter ¶
func WithResetter(fn func()) Option
WithResetter returns an engine option that registers a reset hook with the engine.
fn is a function to be called whenever the engine is reset.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package controller contains interfaces that the engine uses to consume controllers for each of the message handler types.
|
Package controller contains interfaces that the engine uses to consume controllers for each of the message handler types. |
aggregate
Package aggregate provides engine components that handle messages that are routed to aggregate message handlers.
|
Package aggregate provides engine components that handle messages that are routed to aggregate message handlers. |
integration
Package integration provides engine components that handle messages that are routed to integration message handlers.
|
Package integration provides engine components that handle messages that are routed to integration message handlers. |
process
Package process provides engine components that handle messages that are routed to process message handlers.
|
Package process provides engine components that handle messages that are routed to process message handlers. |
projection
Package projection provides engine components that handle messages that are routed to projection message handlers.
|
Package projection provides engine components that handle messages that are routed to projection message handlers. |
Package envelope provides a container for passing Dogma messages and their meta-data between components.
|
Package envelope provides a container for passing Dogma messages and their meta-data between components. |
Package fact contains structures that represents internal engine events.
|
Package fact contains structures that represents internal engine events. |