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(exception, 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.
91 92 93 94 95 96 97 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 91 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
105 106 107 108 109 110 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 105 def delegate_to_service(input) @logger.info 'Received request', input @benchmarker.call(input) { @service.call(input) } rescue StandardError => exception handle_exception(exception, input) end |
#handle_exception(exception, input) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 112 def handle_exception(exception, input) = [exception.inspect, *exception.backtrace].join("\n") @logger.error(, input) if @exception_notifier @exception_notifier.notify_or_ignore( exception, cgi_data: ENV.to_hash, parameters: input ) end end |
#spawn(queue) ⇒ Object
99 100 101 102 103 |
# File 'lib/salemove/process_handler/pivot_process.rb', line 99 def spawn(queue) @freddy.tap_into(queue) do |input| delegate_to_service(input.merge(type: queue)) end end |