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, freddy:, logger:, benchmarker:, exception_notifier:) ⇒ TapServiceSpawner
constructor
A new instance of TapServiceSpawner.
- #spawn(queue) ⇒ Object
Constructor Details
#initialize(service, freddy:, logger:, benchmarker:, exception_notifier:) ⇒ TapServiceSpawner
Returns a new instance of TapServiceSpawner.
105 106 107 108 109 110 111 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 105 def initialize(service, freddy:, logger:, benchmarker:, exception_notifier:) @service = service @freddy = freddy @logger = logger @benchmarker = benchmarker @exception_notifier = exception_notifier end |
Instance Method Details
#delegate_to_service(input) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 119 def delegate_to_service(input) @logger.info 'Received request', PivotProcess.trace_information.merge(input) @benchmarker.call(input) { @service.call(input) } rescue => exception handle_exception(exception, input) end |
#handle_exception(e, input) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 126 def handle_exception(e, input) @logger.error(e.inspect + "\n" + e.backtrace.join("\n"), PivotProcess.trace_information) if @exception_notifier @exception_notifier.notify_or_ignore(e, cgi_data: ENV.to_hash, parameters: input) end end |
#spawn(queue) ⇒ Object
113 114 115 116 117 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 113 def spawn(queue) @freddy.tap_into(queue) do |input| delegate_to_service(input.merge(type: queue)) end end |