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.

Class Method Summary collapse

Class Method Details

.gen_timeout_method(name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/cutoff/patch/net_http.rb', line 11

def self.gen_timeout_method(name)
  <<~RUBY
    if #{name}.nil? || #{name} > remaining
      self.#{name} = cutoff.seconds_remaining
    end
  RUBY
end

.use_write_timeout?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cutoff/patch/net_http.rb', line 19

def self.use_write_timeout?
  Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.6')
end