class SquashRepeater::ExceptionQueue

Public Class Methods

perform(url, headers, body, squash_configuration, no_proxy_env=nil) click to toggle source

Process one captured Squash notification; i.e. forward it to the Squash server

# File lib/squash_repeater/exception_queue.rb, line 74
def self.perform(url, headers, body, squash_configuration, no_proxy_env=nil)
  #TODO: Change how Squash client deals with failures.
  #    Normally it logs to a special log file, whereas what we really want
  #    is for the job(s) to go back on the queue to be retried.

  # If things fail, it's useful to know how long it caused the exception-capture to block the
  # calling process:
  start = Time.now

  #NB: :timeout_protection is a Proc object:
  squash_configuration = squash_configuration.dup

  #NB: The JSON conversion turns symbol-keys --> strings
  #NB: Squash::Ruby.configure turns string-keys --> symbols
  squash_configuration.delete("timeout_protection")

  #NB: This relies on forking behaviour!
  # We do this, because the queue may be shared, therefore the config may have been different from
  # each client.
  Squash::Ruby.configure(squash_configuration)
  ENV['no_proxy'] = no_proxy_env

  begin
    # Transmit it to the Squash server:
    Squash::Ruby.http_transmit__original(url, headers, body)

  rescue SocketError => e
    SquashRepeater.failsafe_handler(e, message: "whilst trying to connect to Squash", time_start: start)
    raise
  end
end