Module: Cutoff::Patch::NetHttp

Defined in:
lib/cutoff/patch/net_http.rb

Overview

Set checkpoints for Ruby HTTP requests. Also sets the Net::HTTP timeouts to the remaining cutoff time. You can select this patch with exclude or only using the checkpoint name :net_http.

Instance Method Summary collapse

Instance Method Details

#startObject

Same as the original start, but adds a checkpoint for starting HTTP requests and sets network timeouts to the remaining time

See Also:

  • Net::HTTP#start


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cutoff/patch/net_http.rb', line 32

module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
  def start
    if (cutoff = Cutoff.current) && cutoff.selected?(:net_http)
      remaining = cutoff.seconds_remaining
      #{gen_timeout_method('open_timeout')}
      #{gen_timeout_method('read_timeout')}
      #{gen_timeout_method('write_timeout') if use_write_timeout?}
      #{gen_timeout_method('continue_timeout')}
      Cutoff.checkpoint!(:net_http)
    end
    super
  end
RUBY