rubygarage / api_struct

API wrapper builder with response serialization
MIT License
234 stars 21 forks source link

Timeout #17

Open jfanals opened 4 years ago

jfanals commented 4 years ago

Is there a way of passing a timeout option (open_timeout, read_timeout, write_timeout) to the http methods?

ozkrpp commented 2 years ago

This wasn't easy so I will share it in case anyone else is struggling with it. You can pass the timeout_options like this if you want a timeout per operation (there is a global timeout as well but I haven't used it):

get('test', headers: request_headers, timeout_class: HTTP::Timeout::PerOperation, timeout_options: {read_timeout: TIMEOUT_VALUE, write_timeout: TIMEOUT_VALUE})

You can also configure connect_timeout