{"action":"created","comment":{"url":"https://api.github.com/repos/lostisland/faraday/pulls/comments/169324098","pull_request_review_id":97826855,"id":169324098,"diff_hunk":"@@ -106,26 +112,32 @@ def initialize(app, options = nil)\n       @errmatch = build_exception_matcher(@options.exceptions)\n     end\n \n-    def sleep_amount(retries)\n+    def sleep_amount(retries, env)\n       retry_index = @options.max - retries\n       current_interval = @options.interval * (@options.backoff_factor ** retry_index)\n       current_interval = [current_interval, @options.max_interval].min\n       random_interval  = rand * @options.interval_randomness.to_f * @options.interval\n-      current_interval + random_interval\n+\n+      retry_after = calculate_retry_after(env)\n+      interval    = current_interval + random_interval\n+\n+      retry_after && retry_after >= interval ? retry_after : interval","path":"lib/faraday/request/retry.rb","position":46,"original_position":46,"commit_id":"7eaa456b3e60fc3d1f022aba93ee7e90282a7f23","original_commit_id":"7eaa456b3e60fc3d1f022aba93ee7e90282a7f23","user":{"login":"iMacTia","id":2527520,"avatar_url":"https://avatars1.githubusercontent.com/u/2527520?v=4","gravatar_id":"","url":"https://api.github.com/users/iMacTia","html_url":"https://github.com/iMacTia","followers_url":"https://api.github.com/users/iMacTia/followers","following_url":"https://api.github.com/users/iMacTia/following{/other_user}","gists_url":"https://api.github.com/users/iMacTia/gists{/gist_id}","starred_url":"https://api.github.com/users/iMacTia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iMacTia/subscriptions","organizations_url":"https://api.github.com/users/iMacTia/orgs","repos_url":"https://api.github.com/users/iMacTia/repos","events_url":"https://api.github.com/users/iMacTia/events{/privacy}","received_events_url":"https://api.github.com/users/iMacTia/received_events","type":"User","site_admin":false},"body":"This method looks a bit too complicated now, so I would separate the logic to calculate the retry interval into a separate method (similarly to what you did with `calculate_retry_after`).\r\nThis new method could be called `calculate_retry_interval(retries)`.","created_at":"2018-02-20T13:54:14Z","updated_at":"2018-02-20T14:00:14Z","html_url":"https://github.com/lostisland/faraday/pull/773#discussion_r169324098","pull_request_url":"https://api.github.com/repos/lostisland/faraday/pulls/773","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/comments/169324098"},"html":{"href":"https://github.com/lostisland/faraday/pull/773#discussion_r169324098"},"pull_request":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/773"}}},"pull_request":{"url":"https://api.github.com/repos/lostisland/faraday/pulls/773","id":170010179,"html_url":"https://github.com/lostisland/faraday/pull/773","diff_url":"https://github.com/lostisland/faraday/pull/773.diff","patch_url":"https://github.com/lostisland/faraday/pull/773.patch","issue_url":"https://api.github.com/repos/lostisland/faraday/issues/773","number":773,"state":"open","locked":false,"title":"Honor Retry-After header","user":{"login":"bronislav","id":125880,"avatar_url":"https://avatars1.githubusercontent.com/u/125880?v=4","gravatar_id":"","url":"https://api.github.com/users/bronislav","html_url":"https://github.com/bronislav","followers_url":"https://api.github.com/users/bronislav/followers","following_url":"https://api.github.com/users/bronislav/following{/other_user}","gists_url":"https://api.github.com/users/bronislav/gists{/gist_id}","starred_url":"https://api.github.com/users/bronislav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bronislav/subscriptions","organizations_url":"https://api.github.com/users/bronislav/orgs","repos_url":"https://api.github.com/users/bronislav/repos","events_url":"https://api.github.com/users/bronislav/events{/privacy}","received_events_url":"https://api.github.com/users/bronislav/received_events","type":"User","site_admin":false},"body":"## Description\r\nImprove retry interval calculations to honor `Retry-After` header if present. This header may be set in case if a server does not respond or request being throttled. \r\n\r\n## Todos\r\nList any remaining work that needs to be done, i.e:\r\n- [x] Tests\r\n- [ ] Documentation\r\n\r\n## Additional Notes\r\nI thought to create separate middleware for this purpose but then decided to just improve existing retry logic.\r\n","created_at":"2018-02-19T16:52:29Z","updated_at":"2018-02-20T14:00:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09ec902bbd8a852d421b7271c51a9ed8d12d9f01","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lostisland/faraday/pulls/773/commits","review_comments_url":"https://api.github.com/repos/lostisland/faraday/pulls/773/comments","review_comment_url":"https://api.github.com/repos/lostisland/faraday/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lostisland/faraday/issues/773/comments","statuses_url":"https://api.github.com/repos/lostisland/faraday/statuses/7eaa456b3e60fc3d1f022aba93ee7e90282a7f23","head":{"label":"bronislav:retry-after-header","ref":"retry-after-header","sha":"7eaa456b3e60fc3d1f022aba93ee7e90282a7f23","user":{"login":"bronislav","id":125880,"avatar_url":"https://avatars1.githubusercontent.com/u/125880?v=4","gravatar_id":"","url":"https://api.github.com/users/bronislav","html_url":"https://github.com/bronislav","followers_url":"https://api.github.com/users/bronislav/followers","following_url":"https://api.github.com/users/bronislav/following{/other_user}","gists_url":"https://api.github.com/users/bronislav/gists{/gist_id}","starred_url":"https://api.github.com/users/bronislav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bronislav/subscriptions","organizations_url":"https://api.github.com/users/bronislav/orgs","repos_url":"https://api.github.com/users/bronislav/repos","events_url":"https://api.github.com/users/bronislav/events{/privacy}","received_events_url":"https://api.github.com/users/bronislav/received_events","type":"User","site_admin":false},"repo":{"id":121791732,"name":"faraday","full_name":"bronislav/faraday","owner":{"login":"bronislav","id":125880,"avatar_url":"https://avatars1.githubusercontent.com/u/125880?v=4","gravatar_id":"","url":"https://api.github.com/users/bronislav","html_url":"https://github.com/bronislav","followers_url":"https://api.github.com/users/bronislav/followers","following_url":"https://api.github.com/users/bronislav/following{/other_user}","gists_url":"https://api.github.com/users/bronislav/gists{/gist_id}","starred_url":"https://api.github.com/users/bronislav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bronislav/subscriptions","organizations_url":"https://api.github.com/users/bronislav/orgs","repos_url":"https://api.github.com/users/bronislav/repos","events_url":"https://api.github.com/users/bronislav/events{/privacy}","received_events_url":"https://api.github.com/users/bronislav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bronislav/faraday","description":"Simple, but flexible HTTP client library, with support for multiple backends.","fork":true,"url":"https://api.github.com/repos/bronislav/faraday","forks_url":"https://api.github.com/repos/bronislav/faraday/forks","keys_url":"https://api.github.com/repos/bronislav/faraday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bronislav/faraday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bronislav/faraday/teams","hooks_url":"https://api.github.com/repos/bronislav/faraday/hooks","issue_events_url":"https://api.github.com/repos/bronislav/faraday/issues/events{/number}","events_url":"https://api.github.com/repos/bronislav/faraday/events","assignees_url":"https://api.github.com/repos/bronislav/faraday/assignees{/user}","branches_url":"https://api.github.com/repos/bronislav/faraday/branches{/branch}","tags_url":"https://api.github.com/repos/bronislav/faraday/tags","blobs_url":"https://api.github.com/repos/bronislav/faraday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bronislav/faraday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bronislav/faraday/git/refs{/sha}","trees_url":"https://api.github.com/repos/bronislav/faraday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bronislav/faraday/statuses/{sha}","languages_url":"https://api.github.com/repos/bronislav/faraday/languages","stargazers_url":"https://api.github.com/repos/bronislav/faraday/stargazers","contributors_url":"https://api.github.com/repos/bronislav/faraday/contributors","subscribers_url":"https://api.github.com/repos/bronislav/faraday/subscribers","subscription_url":"https://api.github.com/repos/bronislav/faraday/subscription","commits_url":"https://api.github.com/repos/bronislav/faraday/commits{/sha}","git_commits_url":"https://api.github.com/repos/bronislav/faraday/git/commits{/sha}","comments_url":"https://api.github.com/repos/bronislav/faraday/comments{/number}","issue_comment_url":"https://api.github.com/repos/bronislav/faraday/issues/comments{/number}","contents_url":"https://api.github.com/repos/bronislav/faraday/contents/{+path}","compare_url":"https://api.github.com/repos/bronislav/faraday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bronislav/faraday/merges","archive_url":"https://api.github.com/repos/bronislav/faraday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bronislav/faraday/downloads","issues_url":"https://api.github.com/repos/bronislav/faraday/issues{/number}","pulls_url":"https://api.github.com/repos/bronislav/faraday/pulls{/number}","milestones_url":"https://api.github.com/repos/bronislav/faraday/milestones{/number}","notifications_url":"https://api.github.com/repos/bronislav/faraday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bronislav/faraday/labels{/name}","releases_url":"https://api.github.com/repos/bronislav/faraday/releases{/id}","deployments_url":"https://api.github.com/repos/bronislav/faraday/deployments","created_at":"2018-02-16T19:29:59Z","updated_at":"2018-02-16T19:30:01Z","pushed_at":"2018-02-19T16:48:10Z","git_url":"git://github.com/bronislav/faraday.git","ssh_url":"git@github.com:bronislav/faraday.git","clone_url":"https://github.com/bronislav/faraday.git","svn_url":"https://github.com/bronislav/faraday","homepage":"","size":1274,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lostisland:master","ref":"master","sha":"c6a2098e081c4f574c8dd6dfabaf578b3c0b738a","user":{"login":"lostisland","id":2613464,"avatar_url":"https://avatars3.githubusercontent.com/u/2613464?v=4","gravatar_id":"","url":"https://api.github.com/users/lostisland","html_url":"https://github.com/lostisland","followers_url":"https://api.github.com/users/lostisland/followers","following_url":"https://api.github.com/users/lostisland/following{/other_user}","gists_url":"https://api.github.com/users/lostisland/gists{/gist_id}","starred_url":"https://api.github.com/users/lostisland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lostisland/subscriptions","organizations_url":"https://api.github.com/users/lostisland/orgs","repos_url":"https://api.github.com/users/lostisland/repos","events_url":"https://api.github.com/users/lostisland/events{/privacy}","received_events_url":"https://api.github.com/users/lostisland/received_events","type":"Organization","site_admin":false},"repo":{"id":417389,"name":"faraday","full_name":"lostisland/faraday","owner":{"login":"lostisland","id":2613464,"avatar_url":"https://avatars3.githubusercontent.com/u/2613464?v=4","gravatar_id":"","url":"https://api.github.com/users/lostisland","html_url":"https://github.com/lostisland","followers_url":"https://api.github.com/users/lostisland/followers","following_url":"https://api.github.com/users/lostisland/following{/other_user}","gists_url":"https://api.github.com/users/lostisland/gists{/gist_id}","starred_url":"https://api.github.com/users/lostisland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lostisland/subscriptions","organizations_url":"https://api.github.com/users/lostisland/orgs","repos_url":"https://api.github.com/users/lostisland/repos","events_url":"https://api.github.com/users/lostisland/events{/privacy}","received_events_url":"https://api.github.com/users/lostisland/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lostisland/faraday","description":"Simple, but flexible HTTP client library, with support for multiple backends.","fork":false,"url":"https://api.github.com/repos/lostisland/faraday","forks_url":"https://api.github.com/repos/lostisland/faraday/forks","keys_url":"https://api.github.com/repos/lostisland/faraday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lostisland/faraday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lostisland/faraday/teams","hooks_url":"https://api.github.com/repos/lostisland/faraday/hooks","issue_events_url":"https://api.github.com/repos/lostisland/faraday/issues/events{/number}","events_url":"https://api.github.com/repos/lostisland/faraday/events","assignees_url":"https://api.github.com/repos/lostisland/faraday/assignees{/user}","branches_url":"https://api.github.com/repos/lostisland/faraday/branches{/branch}","tags_url":"https://api.github.com/repos/lostisland/faraday/tags","blobs_url":"https://api.github.com/repos/lostisland/faraday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lostisland/faraday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lostisland/faraday/git/refs{/sha}","trees_url":"https://api.github.com/repos/lostisland/faraday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lostisland/faraday/statuses/{sha}","languages_url":"https://api.github.com/repos/lostisland/faraday/languages","stargazers_url":"https://api.github.com/repos/lostisland/faraday/stargazers","contributors_url":"https://api.github.com/repos/lostisland/faraday/contributors","subscribers_url":"https://api.github.com/repos/lostisland/faraday/subscribers","subscription_url":"https://api.github.com/repos/lostisland/faraday/subscription","commits_url":"https://api.github.com/repos/lostisland/faraday/commits{/sha}","git_commits_url":"https://api.github.com/repos/lostisland/faraday/git/commits{/sha}","comments_url":"https://api.github.com/repos/lostisland/faraday/comments{/number}","issue_comment_url":"https://api.github.com/repos/lostisland/faraday/issues/comments{/number}","contents_url":"https://api.github.com/repos/lostisland/faraday/contents/{+path}","compare_url":"https://api.github.com/repos/lostisland/faraday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lostisland/faraday/merges","archive_url":"https://api.github.com/repos/lostisland/faraday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lostisland/faraday/downloads","issues_url":"https://api.github.com/repos/lostisland/faraday/issues{/number}","pulls_url":"https://api.github.com/repos/lostisland/faraday/pulls{/number}","milestones_url":"https://api.github.com/repos/lostisland/faraday/milestones{/number}","notifications_url":"https://api.github.com/repos/lostisland/faraday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lostisland/faraday/labels{/name}","releases_url":"https://api.github.com/repos/lostisland/faraday/releases{/id}","deployments_url":"https://api.github.com/repos/lostisland/faraday/deployments","created_at":"2009-12-10T17:14:55Z","updated_at":"2018-02-19T19:52:22Z","pushed_at":"2018-02-19T16:52:29Z","git_url":"git://github.com/lostisland/faraday.git","ssh_url":"git@github.com:lostisland/faraday.git","clone_url":"https://github.com/lostisland/faraday.git","svn_url":"https://github.com/lostisland/faraday","homepage":"","size":1270,"stargazers_count":3895,"watchers_count":3895,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":630,"mirror_url":null,"archived":false,"open_issues_count":23,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":630,"open_issues":23,"watchers":3895,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/773"},"html":{"href":"https://github.com/lostisland/faraday/pull/773"},"issue":{"href":"https://api.github.com/repos/lostisland/faraday/issues/773"},"comments":{"href":"https://api.github.com/repos/lostisland/faraday/issues/773/comments"},"review_comments":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/773/comments"},"review_comment":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lostisland/faraday/pulls/773/commits"},"statuses":{"href":"https://api.github.com/repos/lostisland/faraday/statuses/7eaa456b3e60fc3d1f022aba93ee7e90282a7f23"}},"author_association":"NONE"}}
{"actor":{"display_login":"iMacTia"}}