jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject [jclouds-labs] JCLOUDS-1022: Automatically handle DigitalOcean rate limit (#212)
Date Wed, 21 Oct 2015 22:41:54 GMT

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

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:


-- Commit Summary --

  * JCLOUDS-1022: Automatically handle DigitalOcean rate limit

-- File Changes --

    A digitalocean2/src/main/java/org/jclouds/digitalocean2/config/DigitalOcean2Properties.java
    A digitalocean2/src/main/java/org/jclouds/digitalocean2/config/DigitalOcean2RateLimitModule.java
    M digitalocean2/src/main/java/org/jclouds/digitalocean2/handlers/DigitalOcean2ErrorHandler.java
    A digitalocean2/src/main/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandler.java
    M digitalocean2/src/test/java/org/jclouds/digitalocean2/compute/DigitalOcean2ComputeServiceLiveTest.java
    A digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java
    M digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java

-- Patch Links --


Reply to this email directly or view it on GitHub:

View raw message