{"action":"created","comment":{"url":"https://api.github.com/repos/uber/ringpop/pulls/comments/26052981","id":26052981,"diff_hunk":"@@ -0,0 +1,279 @@\n+// Copyright (c) 2015 Uber Technologies, Inc.\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in\n+// all copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+// THE SOFTWARE.\n+'use strict';\n+\n+var numOrDefault = require('./util.js').numOrDefault;\n+var rawHead = require('./request-proxy-util.js').rawHead;\n+var strHead = require('./request-proxy-util.js').strHead;\n+var TypedError = require('error/typed');\n+\n+var MaxRetriesExceeded = TypedError({\n+    type: 'ringpop.request-proxy.max-retries-exceeded',\n+    message: 'Max number of retries exceeded. ({maxRetries}) were attempted',\n+    maxRetries: null\n+});\n+\n+var RetryDivergenceError = TypedError({\n+    type: 'ringpop.request-proxy.keys-diverged',\n+    message: 'Destinations for proxied request have diverged. These keys: \\n' +\n+        ' {keys}, were originally intended for {origDestination}, but are\\n' +\n+        ' now meant for {newDestinations}.',\n+    keys: null,\n+    origDestination: null,\n+    newDestinations: null\n+});\n+\n+var RETRY_SCHEDULE = [0, 1, 3.5];\n+\n+function RequestProxySend(opts) {\n+    this.ringpop = opts.ringpop;","path":"lib/request-proxy-send.js","position":46,"original_position":46,"commit_id":"c3cefdb8c1ae0132aa1b5d134c9c7d097504beb0","original_commit_id":"c3cefdb8c1ae0132aa1b5d134c9c7d097504beb0","user":{"login":"jwolski","id":16902,"avatar_url":"https://avatars.githubusercontent.com/u/16902?v=3","gravatar_id":"","url":"https://api.github.com/users/jwolski","html_url":"https://github.com/jwolski","followers_url":"https://api.github.com/users/jwolski/followers","following_url":"https://api.github.com/users/jwolski/following{/other_user}","gists_url":"https://api.github.com/users/jwolski/gists{/gist_id}","starred_url":"https://api.github.com/users/jwolski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwolski/subscriptions","organizations_url":"https://api.github.com/users/jwolski/orgs","repos_url":"https://api.github.com/users/jwolski/repos","events_url":"https://api.github.com/users/jwolski/events{/privacy}","received_events_url":"https://api.github.com/users/jwolski/received_events","type":"User","site_admin":false},"body":"This is interesting. I'm not sure if I agree with your suggestion, but I'll let it settle and digest and reevaluate.","created_at":"2015-03-09T16:51:54Z","updated_at":"2015-03-09T16:51:54Z","html_url":"https://github.com/uber/ringpop/pull/41#discussion_r26052981","pull_request_url":"https://api.github.com/repos/uber/ringpop/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/uber/ringpop/pulls/comments/26052981"},"html":{"href":"https://github.com/uber/ringpop/pull/41#discussion_r26052981"},"pull_request":{"href":"https://api.github.com/repos/uber/ringpop/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/uber/ringpop/pulls/41","id":30420693,"html_url":"https://github.com/uber/ringpop/pull/41","diff_url":"https://github.com/uber/ringpop/pull/41.diff","patch_url":"https://github.com/uber/ringpop/pull/41.patch","issue_url":"https://api.github.com/repos/uber/ringpop/issues/41","number":41,"state":"open","locked":false,"title":"Lookup latest destination when retrying a proxied request","user":{"login":"jwolski","id":16902,"avatar_url":"https://avatars.githubusercontent.com/u/16902?v=3","gravatar_id":"","url":"https://api.github.com/users/jwolski","html_url":"https://github.com/jwolski","followers_url":"https://api.github.com/users/jwolski/followers","following_url":"https://api.github.com/users/jwolski/following{/other_user}","gists_url":"https://api.github.com/users/jwolski/gists{/gist_id}","starred_url":"https://api.github.com/users/jwolski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwolski/subscriptions","organizations_url":"https://api.github.com/users/jwolski/orgs","repos_url":"https://api.github.com/users/jwolski/repos","events_url":"https://api.github.com/users/jwolski/events{/privacy}","received_events_url":"https://api.github.com/users/jwolski/received_events","type":"User","site_admin":false},"body":"This is an enhancement to proxied retries. The enhancement addresses the lack of key lookups after proxied requests fail. I've taken this opportunity to abstract away a \"send\" operation into its own class which encapsulates all of the retry logic. Before a retry is attempted, a lookup is performed on the key. If the destination is different, the request is rerouted to the new destination. Otherwise, not rerouted, but still retried. If multiple keys are part of the send operation (when `handleOrProxyAll` is used) and the key destinations diverge after a request fails, then I abort the retry entirely. Handling this nuanced case will be left as an exercise for later. I've essentially ripped out a lot of what was in `request-proxy.js` and moved it into `request-proxy-send.js`. \r\n\r\n@Raynos @robskillington @mrhooray ","created_at":"2015-03-03T22:43:34Z","updated_at":"2015-03-09T16:51:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a40d4e069c48b99272a1db2c05e34b7fe8691c26","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/uber/ringpop/pulls/41/commits","review_comments_url":"https://api.github.com/repos/uber/ringpop/pulls/41/comments","review_comment_url":"https://api.github.com/repos/uber/ringpop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/ringpop/issues/41/comments","statuses_url":"https://api.github.com/repos/uber/ringpop/statuses/c3cefdb8c1ae0132aa1b5d134c9c7d097504beb0","head":{"label":"uber:retrylookup","ref":"retrylookup","sha":"c3cefdb8c1ae0132aa1b5d134c9c7d097504beb0","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":29378455,"name":"ringpop","full_name":"uber/ringpop","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/ringpop","description":"Scalable, fault-tolerant application-layer sharding","fork":false,"url":"https://api.github.com/repos/uber/ringpop","forks_url":"https://api.github.com/repos/uber/ringpop/forks","keys_url":"https://api.github.com/repos/uber/ringpop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/ringpop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/ringpop/teams","hooks_url":"https://api.github.com/repos/uber/ringpop/hooks","issue_events_url":"https://api.github.com/repos/uber/ringpop/issues/events{/number}","events_url":"https://api.github.com/repos/uber/ringpop/events","assignees_url":"https://api.github.com/repos/uber/ringpop/assignees{/user}","branches_url":"https://api.github.com/repos/uber/ringpop/branches{/branch}","tags_url":"https://api.github.com/repos/uber/ringpop/tags","blobs_url":"https://api.github.com/repos/uber/ringpop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/ringpop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/ringpop/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/ringpop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/ringpop/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/ringpop/languages","stargazers_url":"https://api.github.com/repos/uber/ringpop/stargazers","contributors_url":"https://api.github.com/repos/uber/ringpop/contributors","subscribers_url":"https://api.github.com/repos/uber/ringpop/subscribers","subscription_url":"https://api.github.com/repos/uber/ringpop/subscription","commits_url":"https://api.github.com/repos/uber/ringpop/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/ringpop/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/ringpop/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/ringpop/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/ringpop/contents/{+path}","compare_url":"https://api.github.com/repos/uber/ringpop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/ringpop/merges","archive_url":"https://api.github.com/repos/uber/ringpop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/ringpop/downloads","issues_url":"https://api.github.com/repos/uber/ringpop/issues{/number}","pulls_url":"https://api.github.com/repos/uber/ringpop/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/ringpop/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/ringpop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/ringpop/labels{/name}","releases_url":"https://api.github.com/repos/uber/ringpop/releases{/id}","created_at":"2015-01-17T03:26:35Z","updated_at":"2015-03-09T16:04:42Z","pushed_at":"2015-03-07T16:23:15Z","git_url":"git://github.com/uber/ringpop.git","ssh_url":"git@github.com:uber/ringpop.git","clone_url":"https://github.com/uber/ringpop.git","svn_url":"https://github.com/uber/ringpop","homepage":"","size":2008,"stargazers_count":44,"watchers_count":44,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":16,"forks":1,"open_issues":16,"watchers":44,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"f16cd941be43b3829651f17ff6e0a74962b38d1b","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":29378455,"name":"ringpop","full_name":"uber/ringpop","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/ringpop","description":"Scalable, fault-tolerant application-layer sharding","fork":false,"url":"https://api.github.com/repos/uber/ringpop","forks_url":"https://api.github.com/repos/uber/ringpop/forks","keys_url":"https://api.github.com/repos/uber/ringpop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/ringpop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/ringpop/teams","hooks_url":"https://api.github.com/repos/uber/ringpop/hooks","issue_events_url":"https://api.github.com/repos/uber/ringpop/issues/events{/number}","events_url":"https://api.github.com/repos/uber/ringpop/events","assignees_url":"https://api.github.com/repos/uber/ringpop/assignees{/user}","branches_url":"https://api.github.com/repos/uber/ringpop/branches{/branch}","tags_url":"https://api.github.com/repos/uber/ringpop/tags","blobs_url":"https://api.github.com/repos/uber/ringpop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/ringpop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/ringpop/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/ringpop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/ringpop/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/ringpop/languages","stargazers_url":"https://api.github.com/repos/uber/ringpop/stargazers","contributors_url":"https://api.github.com/repos/uber/ringpop/contributors","subscribers_url":"https://api.github.com/repos/uber/ringpop/subscribers","subscription_url":"https://api.github.com/repos/uber/ringpop/subscription","commits_url":"https://api.github.com/repos/uber/ringpop/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/ringpop/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/ringpop/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/ringpop/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/ringpop/contents/{+path}","compare_url":"https://api.github.com/repos/uber/ringpop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/ringpop/merges","archive_url":"https://api.github.com/repos/uber/ringpop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/ringpop/downloads","issues_url":"https://api.github.com/repos/uber/ringpop/issues{/number}","pulls_url":"https://api.github.com/repos/uber/ringpop/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/ringpop/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/ringpop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/ringpop/labels{/name}","releases_url":"https://api.github.com/repos/uber/ringpop/releases{/id}","created_at":"2015-01-17T03:26:35Z","updated_at":"2015-03-09T16:04:42Z","pushed_at":"2015-03-07T16:23:15Z","git_url":"git://github.com/uber/ringpop.git","ssh_url":"git@github.com:uber/ringpop.git","clone_url":"https://github.com/uber/ringpop.git","svn_url":"https://github.com/uber/ringpop","homepage":"","size":2008,"stargazers_count":44,"watchers_count":44,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":16,"forks":1,"open_issues":16,"watchers":44,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/ringpop/pulls/41"},"html":{"href":"https://github.com/uber/ringpop/pull/41"},"issue":{"href":"https://api.github.com/repos/uber/ringpop/issues/41"},"comments":{"href":"https://api.github.com/repos/uber/ringpop/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/ringpop/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/ringpop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/ringpop/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/uber/ringpop/statuses/c3cefdb8c1ae0132aa1b5d134c9c7d097504beb0"}}}}