Class: Sequent::Core::Workflow
Class Method Summary
collapse
Instance Method Summary
collapse
#handle_message, included
Class Method Details
.on(*message_classes, &block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/sequent/core/workflow.rb', line 9
def self.on(*message_classes, &block)
decorated_block = ->(event) do
begin
old_event = CurrentEvent.current
CurrentEvent.current = event
self.instance_exec(event, &block)
ensure
CurrentEvent.current = old_event
end
end
super(*message_classes, &decorated_block)
end
|
Instance Method Details
#after_commit(ignore_errors: false, &block) ⇒ Object
Workflow#after_commit will accept a block to execute after the transaction commits. This is very useful to isolate side-effects. They will run only on the transaction’s success and will not be able to roll it back when there is an exception. Useful if your background jobs processor is not using the same database connection to enqueue jobs.
33
34
35
36
37
38
39
40
41
|
# File 'lib/sequent/core/workflow.rb', line 33
def after_commit(ignore_errors: false, &block)
Sequent.configuration.transaction_provider.after_commit &block
rescue StandardError => error
if ignore_errors
Sequent.logger.warn("An exception was raised in an after_commit hook: #{error}, #{error.inspect}")
else
raise error
end
end
|
#execute_commands(*commands) ⇒ Object
22
23
24
|
# File 'lib/sequent/core/workflow.rb', line 22
def execute_commands(*commands)
Sequent.configuration.command_service.execute_commands(*commands)
end
|