module SquashRepeater

Configuration methods are in `configure.rb` Exception capture and re-run are in `exception_queue.rb`

Constants

VERSION
WORKER_ERRORS

Attributes

configuration[RW]

Public Class Methods

capture_exception(url: nil, headers: nil, body: nil, squash_configuration: nil, no_proxy_env: nil) click to toggle source

Capture the HTTP data, and store it in the beanstalkd queue for later

# File lib/squash_repeater/exception_queue.rb, line 28
def capture_exception(url: nil, headers: nil, body: nil, squash_configuration: nil, no_proxy_env: nil)
  #FUTURE: Required keyword args, for Ruby 2.1+
  #def capture_exception(url:, headers:, body:, squash_configuration:, no_proxy_env: nil)
  fail "Missing required keyword arg" unless url && headers && body && squash_configuration

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

  begin
    Timeout::timeout(configuration.capture_timeout, CaptureTimeoutError) do
      #NB: Backburner doesn't seem able to #perform with keyword args:
      Backburner.enqueue(ExceptionQueue, url, headers, body, squash_configuration, no_proxy_env)
    end

  rescue *WORKER_ERRORS => e
    failsafe_handler(
      e, message: "whilst trying to connect to Beanstalk", time_start: start,
      args: {
        url: url,
        headers: headers,
        body: body,
        squash_configuration: squash_configuration,
        no_proxy_env: no_proxy_env
      }
    )
    raise
  end
end
Also aliased as: enqueue
configure() { |configuration| ... } click to toggle source
# File lib/squash_repeater/configure.rb, line 9
def self.configure
  self.configuration ||= Configuration.new  # Initialise
  yield configuration if block_given?
end
enqueue(url: nil, headers: nil, body: nil, squash_configuration: nil, no_proxy_env: nil)
Alias for: capture_exception
failsafe_handler(exception, message: nil, time_start: nil, args: {}) click to toggle source
# File lib/squash_repeater/exception_queue.rb, line 59
def failsafe_handler(exception, message: nil, time_start: nil, args: {})
  configuration.logger.error "Failed: #{exception}" + (message && !message.empty? ? ", #{message}." : ".")
  configuration.logger.error "      : #{exception.inspect}"

  configuration.logger.error "  (Took #{Time.now - time_start}s to fail)" if time_start
  configuration.logger.error ["*****","  original_args = #{args.inspect}", "*****"].join("\n")
end
transmit_exceptions() click to toggle source
# File lib/squash_repeater/exception_queue.rb, line 22
def transmit_exceptions
  Backburner.work
end
Also aliased as: work
work()
Alias for: transmit_exceptions