auth0-python icon indicating copy to clipboard operation
auth0-python copied to clipboard

Parameterize maximum delay

Open ankona opened this issue 3 years ago • 0 comments

Allows a client to specify retry delays in the range [MIN_REQUEST_RETRY_DELAY, 4s].

Current retry maximum delay is set to 1000ms. Under minor load, this may cause failures in non-production Auth0 tenants. Parameterizing the maximum delay while retaining the existing default gives flexibility to a client when responsiveness is less important.

Changes

RestClientOptions

  • Add additional rest option to set a maximum allowed delay in the event of a 429 retry.

RestClient

  • increase MAX_REQUEST_RETRY_DELAY to 4s
  • Use options.delay value in lieu of the existing 1s cap provided by MAX_REQUEST_RETRY_DELAY

Usage:

  • When no options are passed, the client defaults to a 1000ms delay per existing behavior.

  • When client desires a new maximum (up to a new hard limit of 4000ms), the min/max logic continues to ensure the hard maximum is not exceeded.

options = RestClientOptions(delay=4000)
client = RestClient(options=options)
...

Alternative:

Simple change of MAX_REQUEST_RETRY_DELAY to 4000 I avoided this to maintain expected behavior with existing clients.

References

n/a

Testing

Unit tests have been added that respect the increased maximum hard limit and that any value in the range [MIN_REQUEST_RETRY_DELAY-MAX_REQUEST_RETRY_DELAY] can be supplied.

  • [X] This change adds unit test coverage
  • [ ] This change adds integration test coverage
  • [X] This change has been tested on the latest version of the platform/language or why not

Checklist

ankona avatar Jul 01 '22 21:07 ankona