Class: Sequent::Core::CommandService
- Inherits:
-
Object
- Object
- Sequent::Core::CommandService
- Defined in:
- lib/sequent/core/command_service.rb
Overview
Single point in the application where subclasses of Sequent::Core::BaseCommand are executed. This will initiate the entire flow of:
-
Validate command
-
Call correct Sequent::Core::BaseCommandHandler
-
CommandHandler decides which Sequent::Core::AggregateRoot (s) to call
-
Events are stored in the Sequent::Core::EventStore
-
Unit of Work is cleared
Instance Method Summary collapse
-
#execute_commands(*commands) ⇒ Object
Executes the given commands in a single transactional block as implemented by the
transaction_provider
. - #remove_event_handler(clazz) ⇒ Object
Instance Method Details
#execute_commands(*commands) ⇒ Object
Executes the given commands in a single transactional block as implemented by the transaction_provider
For each command:
-
All filters are executed. Any exception raised will rollback the transaction and propagate up
-
If the command is valid all
command_handlers
thathandles_message?
is invoked -
The
repository
commits the command and all uncommitted_events resulting from the command
23 24 25 26 |
# File 'lib/sequent/core/command_service.rb', line 23 def execute_commands(*commands) commands.each { |command| command_queue.push(command) } process_commands end |
#remove_event_handler(clazz) ⇒ Object
28 29 30 |
# File 'lib/sequent/core/command_service.rb', line 28 def remove_event_handler(clazz) event_store.remove_event_handler(clazz) end |