Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea: global timeout settings #176

Closed
jjb opened this issue May 6, 2024 · 1 comment · Fixed by #177
Closed

idea: global timeout settings #176

jjb opened this issue May 6, 2024 · 1 comment · Fixed by #177

Comments

@jjb
Copy link

jjb commented May 6, 2024

faraday allows setting global timeouts

Faraday.default_connection_options = Faraday::ConnectionOptions.new({
  open_timeout: ENV.fetch('NET_HTTP_OPEN_TIMEOUT', 5).to_f,
  timeout: ENV.fetch('NET_HTTP_TIMEOUT', 30).to_f
})

If i set this, then i know all my own code which uses faraday, and gems that i use which use faraday (and don't set their own timeouts, which seems to usually be the case), will have this timeout set.

for net-http, i can do some combination of the bellow:

a) set it one by one for my own code
b) ask gem authors to allow this to be configured when it's not
c) monkeypatch gems
d) do a global monkeypatch of net-http
e) use the http-cage gem which has't been updated in 3 years (but maybe doesn't need to be, haven't really checked)

it would be great if net-http allowed a global setting, similar to faraday

i would be happy to submit a PR if folks think it's a good idea

@jjb
Copy link
Author

jjb commented May 9, 2024

here is the meat of the monkeypatch, applied with this method

    # on Net::HTTP
    def initialize(*)
      super
      self.open_timeout = 
      self.read_timeout = 
      self.write_timeout = 
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant