Module: SquashRepeater
- Defined in:
- lib/squash_repeater.rb,
lib/squash_repeater/version.rb,
lib/squash_repeater/configure.rb,
lib/squash_repeater/exception_queue.rb,
lib/generators/squash_repeater/install_generator.rb
Overview
Configuration methods are in ‘configure.rb` Exception capture and re-run are in `exception_queue.rb`
Defined Under Namespace
Modules: Generators Classes: CaptureTimeoutError, Configuration, Error, ExceptionQueue
Constant Summary collapse
- VERSION =
"0.1.9.1"
- WORKER_ERRORS =
[ Beaneater::NotConnected, Beaneater::InvalidTubeName, Beaneater::JobNotReserved, Beaneater::UnexpectedResponse ]
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.capture_exception(url: nil, headers: nil, body: nil, squash_configuration: nil, no_proxy_env: nil) ⇒ Object
(also: enqueue)
Capture the HTTP data, and store it in the beanstalkd queue for later.
- .configure {|configuration| ... } ⇒ Object
- .failsafe_handler(exception, message: nil, time_start: nil, args: {}) ⇒ Object
- .transmit_exceptions ⇒ Object (also: work)
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
6 7 8 |
# File 'lib/squash_repeater/configure.rb', line 6 def configuration @configuration end |
Class Method Details
.capture_exception(url: nil, headers: nil, body: nil, squash_configuration: nil, no_proxy_env: nil) ⇒ Object Also known as: enqueue
Capture the HTTP data, and store it in the beanstalkd queue for later
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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 |
.configure {|configuration| ... } ⇒ Object
9 10 11 12 |
# File 'lib/squash_repeater/configure.rb', line 9 def self.configure self.configuration ||= Configuration.new # Initialise yield configuration if block_given? end |
.failsafe_handler(exception, message: nil, time_start: nil, args: {}) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/squash_repeater/exception_queue.rb', line 59 def failsafe_handler(exception, message: nil, time_start: nil, args: {}) configuration.logger.error "Failed: #{exception}" + ( && !.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 ⇒ Object Also known as: work
22 23 24 |
# File 'lib/squash_repeater/exception_queue.rb', line 22 def transmit_exceptions Backburner.work end |