Class: SquashRepeater::ExceptionQueue

Inherits:
Object
  • Object
show all
Includes:
Backburner::Queue
Defined in:
lib/squash_repeater/exception_queue.rb

Class Method Summary collapse

Class Method Details

.perform(url, headers, body, squash_configuration, no_proxy_env = nil) ⇒ Object

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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# 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