Class: Salemove::ProcessHandler::PivotProcess::TapServiceSpawner

Inherits:
Object
  • Object
show all
Defined in:
lib/salemove/process_handler/pivot_process.rb

Instance Method Summary collapse

Constructor Details

#initialize(service, freddy, exception_notifier) ⇒ TapServiceSpawner

Returns a new instance of TapServiceSpawner.



99
100
101
102
103
# File 'lib/salemove/process_handler/pivot_process.rb', line 99

def initialize(service, freddy, exception_notifier)
  @service = service
  @freddy = freddy
  @exception_notifier = exception_notifier
end

Instance Method Details

#delegate_to_service(input) ⇒ Object



111
112
113
114
115
116
# File 'lib/salemove/process_handler/pivot_process.rb', line 111

def delegate_to_service(input)
  PivotProcess.logger.info "Received request", PivotProcess.trace_information.merge(input)
  PivotProcess.benchmark(input) { @service.call(input) }
rescue => exception
  handle_exception(exception, input)
end

#handle_exception(e, input) ⇒ Object



118
119
120
121
122
123
# File 'lib/salemove/process_handler/pivot_process.rb', line 118

def handle_exception(e, input)
  PivotProcess.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



105
106
107
108
109
# File 'lib/salemove/process_handler/pivot_process.rb', line 105

def spawn(queue)
  @freddy.tap_into(queue) do |input|
    delegate_to_service(input.merge(type: queue))
  end
end