Skip to content

Commit

Permalink
Support custom client retry backoff delay, sleep before requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoene committed Sep 17, 2014
1 parent ce3048c commit d91f76e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/frenchy/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(options={})
@host = options.delete("host") || "http://127.0.0.1:8080"
@timeout = options.delete("timeout") || 30
@retries = options.delete("retries") || 0
@backoff_delay = options.delete("backoff_delay") || 1.0
end

# Issue a get request with the given path and query parameters. Get
Expand All @@ -20,11 +21,12 @@ def get(path, params)
try = 0
err = nil

while try <= @retries
while try < @retries
sleep (@backoff_delay * (try*try)) if try > 0

begin
return perform("GET", path, params)
rescue Frenchy::Error => err
sleep (0.35 * (try*try))
try += 1
end
end
Expand Down

0 comments on commit d91f76e

Please sign in to comment.