https://issues.apache.org/jira/browse/JCLOUDS-1022
This pull request introduces a retry handler to deal with the [DigitalOcean
rate limit](https://developers.digitalocean.com/documentation/v2/#rate-limit).
The retry handler will read the rate limit information provided in the response
to determine the amount of time the request has to be delayed. It will block
the execution thread that amount of time, to finally return `true` so the
command executor executing the request will retry it.
It is basically the same retry mechanism that is used to follow redirects, but
introducing an active wait *before* returning if the request has to be retried
or not. This allows us to apply this directly in the http layer, making it
transparent to all the code and request execution.
The rate limit is disabled by default, and rate limit failures will be
propagated as `RateLimitExceededExceptions` (note this PR depends on
https://github.com/jclouds/jclouds/pull/867 and the build may fail until the
latest snapshots are published). To use the rate limit features users will just
have to include the `DigitalOcean2rateLimitModule` when creating the context.
The `jclouds.max-retries` and the `jclouds.jclouds.max-ratelimit-wait` can be
used to customize the number of retries and the maximum acceptable time to wait
for a rate limited request,
/cc @ccustine Feedback is very welcome!
You can view, comment on, or merge this pull request online at:
https://github.com/jclouds/jclouds-labs/pull/212
-- Commit Summary --
* JCLOUDS-1022: Automatically handle DigitalOcean rate limit
-- File Changes --
A
digitalocean2/src/main/java/org/jclouds/digitalocean2/config/DigitalOcean2Properties.java
(33)
A
digitalocean2/src/main/java/org/jclouds/digitalocean2/config/DigitalOcean2RateLimitModule.java
(30)
M
digitalocean2/src/main/java/org/jclouds/digitalocean2/handlers/DigitalOcean2ErrorHandler.java
(23)
A
digitalocean2/src/main/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandler.java
(108)
M
digitalocean2/src/test/java/org/jclouds/digitalocean2/compute/DigitalOcean2ComputeServiceLiveTest.java
(8)
A
digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java
(153)
M
digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java
(7)
-- Patch Links --
https://github.com/jclouds/jclouds-labs/pull/212.patch
https://github.com/jclouds/jclouds-labs/pull/212.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/212