Module: HTTPX::Plugins::Persistent::InstanceMethods

Defined in:
lib/httpx/plugins/persistent.rb,
sig/plugins/persistent.rbs

Instance Method Summary collapse

Instance Method Details

#closeObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/httpx/plugins/persistent.rb', line 45

def close(*)
  super

  # traverse other threads and unlink respective selector
  # WARNING: this is not thread safe, make sure that the session isn't being
  # used anymore, or all non-main threads are stopped.
  Thread.list.each do |th|
    store = thread_selector_store(th)

    next unless store && store.key?(self)

    selector = store.delete(self)

    selector_close(selector)
  end
end

#reconnectable_error?(error) ⇒ Boolean

Parameters:

  • error (StandardError)

Returns:

  • (Boolean)


64
65
66
# File 'lib/httpx/plugins/persistent.rb', line 64

def reconnectable_error?(error)
  Retries::RECONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
end

#safe_reconnectable_error?(error) ⇒ Boolean

whether the error can be safely retried without booking threshold attempts.

Parameters:

  • error (StandardError)

Returns:

  • (Boolean)


69
70
71
# File 'lib/httpx/plugins/persistent.rb', line 69

def safe_reconnectable_error?(error)
  SAFE_REONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
end