Class: Salemove::ProcessHandler::PivotProcess::TapServiceSpawner
- Inherits:
-
Object
- Object
- Salemove::ProcessHandler::PivotProcess::TapServiceSpawner
- Defined in:
- lib/salemove/process_handler/pivot_process.rb
Instance Method Summary collapse
- #delegate_to_service(input) ⇒ Object
- #handle_exception(e, input) ⇒ Object
-
#initialize(service, messenger, exception_notifier) ⇒ TapServiceSpawner
constructor
A new instance of TapServiceSpawner.
- #spawn(queue) ⇒ Object
Constructor Details
#initialize(service, messenger, exception_notifier) ⇒ TapServiceSpawner
Returns a new instance of TapServiceSpawner.
85 86 87 88 89 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 85 def initialize(service, messenger, exception_notifier) @service = service @messenger = messenger @exception_notifier = exception_notifier end |
Instance Method Details
#delegate_to_service(input) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 98 def delegate_to_service(input) PivotProcess.logger.info "Received request", input PivotProcess.benchmark(input) { @service.call(input) } rescue => exception handle_exception(exception, input) end |
#handle_exception(e, input) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 105 def handle_exception(e, input) PivotProcess.logger.error(e.inspect + "\n" + e.backtrace.join("\n"), request_id: input[:request_id]) if @exception_notifier @exception_notifier.notify_or_ignore(e, cgi_data: ENV.to_hash, parameters: input) end end |
#spawn(queue) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 91 def spawn(queue) @messenger.tap_into(queue) do |input| request_id = SecureRandom.hex(5) delegate_to_service(input.merge(type: queue, request_id: request_id)) end end |