module HTTPX::Plugins::Persistent

  1. lib/httpx/plugins/persistent.rb

This plugin implements a session that persists connections over the duration of the process.

This will improve connection reuse in a long-running process.

One important caveat to note is, although this session might not close connections, other sessions from the same process that don't have this plugin turned on might.

This session will still be able to work with it, as if, when expecting a connection terminated by a different session, it will just retry on a new one and keep it open.

This plugin is also not recommendable when connecting to >9000 (like, a lot) different origins. So when you use this, make sure that you don't fall into this trap.


Public Class

  1. extra_options
  2. load_dependencies

Public Class methods

extra_options (options)
[show source]
   # File lib/httpx/plugins/persistent.rb
25 def self.extra_options(options)
26   options.merge(persistent: true)
27 end
load_dependencies (klass)
[show source]
   # File lib/httpx/plugins/persistent.rb
21 def self.load_dependencies(klass)
22   klass.plugin(:retries, max_retries: 1, retry_change_requests: true)
23 end