module Sequent::Util::DryRun
Dry run provides the ability to inspect what would happen if the given commands would be executed without actually committing the results. You can inspect which commands are executed and what the resulting events would be with theSequent::Projector’s and Sequent::Workflow
‘s that would be invoked (without actually invoking them).
Since the Workflow’s are not actually invoked new commands resulting from this Workflow
will of course not be in the result.
Caution: Since the Sequent
Configuration
is shared between threads this method is not Thread safe.
Example usage:
result = Sequent.dry_run(create_foo_command, ping_foo_command) result.print(STDOUT)
Constants
- EventInvokedHandler
Public Class Methods
Main method of the DryRun
.
Caution: Since the Sequent
Configuration
is changed and is shared between threads this method is not Thread safe.
After invocation the sequent configuration is reset to the state it was before invoking this method.
@param commands - the commands to dry run @return Result
- the Result
of the dry run. See Result
.
# File lib/sequent/util/dry_run.rb, line 177 def self.these_commands(commands) current_event_store = Sequent.configuration.event_store current_event_publisher = Sequent.configuration.event_publisher current_transaction_provider = Sequent.configuration.transaction_provider result = Result.new Sequent.configuration.event_store = EventStoreProxy.new(result, current_event_store) Sequent.configuration.event_publisher = RecordingEventPublisher.new(result) Sequent.configuration.transaction_provider = Sequent::Core::Transactions::ReadOnlyActiveRecordTransactionProvider.new(current_transaction_provider) Sequent.command_service.execute_commands(*commands) result ensure Sequent.configuration.event_store = current_event_store Sequent.configuration.event_publisher = current_event_publisher Sequent.configuration.transaction_provider = current_transaction_provider end