avadev / AvaTax-REST-V2-Ruby-SDK

Sales Tax API SDK for Ruby and AvaTax REST
https://developer.avalara.com/sdk/
Apache License 2.0
36 stars 56 forks source link

Can no longer set custom SDK timeout after v20.1.1 #81

Closed oehlschl closed 2 years ago

oehlschl commented 4 years ago

Our application has a 15s timeout for web requests, so we previously lowered the read timeout for the Avalara SDK to 8s. Most requests for tax estimation took well under 8s already, and it's preferable for us to handle the timeout, trigger offline tax calculation, and do other request cleanup ourselves versus hitting the global application timeout hander where we have much less control.

Setting custom timeouts for an SDK is a common need and was possible using the connection_options config setting like so:

AvaTax.configure do |config|
  # ...
  config.connection_options = {
    request: {
      open_timeout: 3.seconds,
      timeout: 8.seconds
    }
  }
end

https://github.com/avadev/AvaTax-REST-V2-Ruby-SDK/blob/eb7c20b8e925a3d682f6414207e298e519e0a549/lib/avatax/configuration.rb#L16

These options ultimately get used to instantiate the Faraday request object in the AvaTax::Connection and control the request timeout. (Documentation: https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts#faraday)

However, in https://github.com/avadev/AvaTax-REST-V2-Ruby-SDK/pull/72, any custom timeout options are overridden in the request method, to what looks like 1200s. This means that clients can no longer set custom timeouts on that request, though it would seem like the connection_options setting was added to enable that type of use case.

Would it instead be possible to set the timeout in the default connection options and have the same effect? https://github.com/avadev/AvaTax-REST-V2-Ruby-SDK/blob/eb7c20b8e925a3d682f6414207e298e519e0a549/lib/avatax/configuration.rb#L32

svc-developer commented 2 years ago

Comment : closing issue as the fix is merged