Class: Yes::Core::Commands::Processor
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Yes::Core::Commands::Processor
- Includes:
- OpenTelemetry::Trackable
- Defined in:
- lib/yes/core/commands/processor.rb
Overview
Processes commands asynchronously through ActiveJob
Constant Summary collapse
- UnregisteredCommand =
Error raised when a command is not registered with a handler
Class.new(Error)
Instance Method Summary collapse
-
#perform(origin, command_or_commands, notifier_options, custom_batch_id = nil, inline = false) ⇒ Array<Response>
Processes the given commands by running them through their respective handlers.
Instance Method Details
#perform(origin, command_or_commands, notifier_options, custom_batch_id = nil, inline = false) ⇒ Array<Response>
Processes the given commands by running them through their respective handlers.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/yes/core/commands/processor.rb', line 27 def perform(origin, command_or_commands, , custom_batch_id = nil, inline = false) setup(, custom_batch_id, inline) singleton_class.current_span&.add_event('Command Processor Setup Done') commands = [*command_or_commands] ensure_guard_evaluators_exist?(commands) singleton_class.current_span&.add_event('Ensured Guard Evaluators Exist') commands.map! { |cmd| cmd.class.new(cmd.to_h.merge(origin:, batch_id:)) } singleton_class.current_span&.add_event('Commands Mapped') if command_notifiers.any? singleton_class.with_otl_span 'Run Commands With Notifiers' do Notifier.with_batch_notification(command_notifiers, batch_id, commands) do singleton_class.with_otl_span 'Run Commands' do run_commands(commands) end end end else singleton_class.with_otl_span 'Run Commands' do run_commands(commands) end end end |