{"action":"created","comment":{"url":"https://api.github.com/repos/line/armeria/pulls/comments/231370110","pull_request_review_id":172326761,"id":231370110,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTM3MDExMA==","diff_hunk":"@@ -21,48 +21,53 @@\n import java.util.concurrent.CompletionStage;\n import java.util.function.BiFunction;\n \n+import javax.annotation.Nullable;\n+\n+import com.linecorp.armeria.client.ClientRequestContext;\n import com.linecorp.armeria.client.ResponseTimeoutException;\n import com.linecorp.armeria.client.UnprocessedRequestException;\n import com.linecorp.armeria.client.circuitbreaker.FailFastException;\n-import com.linecorp.armeria.common.Flags;\n-import com.linecorp.armeria.common.HttpRequest;\n-import com.linecorp.armeria.common.HttpResponse;\n+import com.linecorp.armeria.common.HttpHeaders;\n import com.linecorp.armeria.common.HttpStatus;\n import com.linecorp.armeria.common.HttpStatusClass;\n-import com.linecorp.armeria.common.Request;\n import com.linecorp.armeria.common.Response;\n import com.linecorp.armeria.common.util.Exceptions;\n \n /**\n  * Determines whether a failed request should be retried.\n- * @param <I> the request type\n- * @param <O> the response type\n+ * If you need to determine by looking into the {@link Response}, use {@link RetryStrategyWithContent}.\n  */\n @FunctionalInterface\n-public interface RetryStrategy<I extends Request, O extends Response> {\n+public interface RetryStrategy {\n \n-    Backoff defaultBackoff = Backoff.of(Flags.defaultBackoffSpec());\n+    /**\n+     * The default {@link Backoff} implementation.\n+     *\n+     * @deprecated use {@link Backoff#defaultBackoff}\n+     */\n+    @Deprecated\n+    Backoff defaultBackoff = Backoff.defaultBackoff;","path":"core/src/main/java/com/linecorp/armeria/client/retry/RetryStrategy.java","position":37,"original_position":37,"commit_id":"7ab99157b7d727b42bc16cb66e1c63d9b1867ecc","original_commit_id":"7ab99157b7d727b42bc16cb66e1c63d9b1867ecc","user":{"login":"trustin","id":173918,"node_id":"MDQ6VXNlcjE3MzkxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/173918?v=4","gravatar_id":"","url":"https://api.github.com/users/trustin","html_url":"https://github.com/trustin","followers_url":"https://api.github.com/users/trustin/followers","following_url":"https://api.github.com/users/trustin/following{/other_user}","gists_url":"https://api.github.com/users/trustin/gists{/gist_id}","starred_url":"https://api.github.com/users/trustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trustin/subscriptions","organizations_url":"https://api.github.com/users/trustin/orgs","repos_url":"https://api.github.com/users/trustin/repos","events_url":"https://api.github.com/users/trustin/events{/privacy}","received_events_url":"https://api.github.com/users/trustin/received_events","type":"User","site_admin":false},"body":":+1:","created_at":"2018-11-07T03:20:33Z","updated_at":"2018-11-07T03:53:09Z","html_url":"https://github.com/line/armeria/pull/1418#discussion_r231370110","pull_request_url":"https://api.github.com/repos/line/armeria/pulls/1418","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/line/armeria/pulls/comments/231370110"},"html":{"href":"https://github.com/line/armeria/pull/1418#discussion_r231370110"},"pull_request":{"href":"https://api.github.com/repos/line/armeria/pulls/1418"}}},"pull_request":{"url":"https://api.github.com/repos/line/armeria/pulls/1418","id":226870611,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2ODcwNjEx","html_url":"https://github.com/line/armeria/pull/1418","diff_url":"https://github.com/line/armeria/pull/1418.diff","patch_url":"https://github.com/line/armeria/pull/1418.patch","issue_url":"https://api.github.com/repos/line/armeria/issues/1418","number":1418,"state":"open","locked":false,"title":"Split RetryStrategy into RetryStrategy and RetryStrategyWithContent","user":{"login":"minwoox","id":25103250,"node_id":"MDQ6VXNlcjI1MTAzMjUw","avatar_url":"https://avatars2.githubusercontent.com/u/25103250?v=4","gravatar_id":"","url":"https://api.github.com/users/minwoox","html_url":"https://github.com/minwoox","followers_url":"https://api.github.com/users/minwoox/followers","following_url":"https://api.github.com/users/minwoox/following{/other_user}","gists_url":"https://api.github.com/users/minwoox/gists{/gist_id}","starred_url":"https://api.github.com/users/minwoox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minwoox/subscriptions","organizations_url":"https://api.github.com/users/minwoox/orgs","repos_url":"https://api.github.com/users/minwoox/repos","events_url":"https://api.github.com/users/minwoox/events{/privacy}","received_events_url":"https://api.github.com/users/minwoox/received_events","type":"User","site_admin":false},"body":"Motivation:\r\nWhen using `RetryingHttpClient`, we use `HttpResponseDuplicator` to duplicate the `HttpResponse` in order to determine to retry or not.\r\nHowever, in most cases, we just need the response headers to decide and don't need the content.\r\nIf we see the content only when we really have to, we can minimize the usage of duplicator which reduces the performance. This approach works for `CircuitBreakerHttpClient` as well.\r\n\r\nModifications:\r\n- Change the method of `RetryStrategy` to `shouldRetry(RequestContext ctx, Throwable cause)`\r\n- Add `RetryStrategyWithContent`\r\n- Add `CircuitBreakerClientBuiler`\r\n- Change the method of `CircuitBreakerStrategy` to `shouldReportAsSuccess(RequestContext ctx, Throwable cause)`\r\n- Add `CircuitBreakerStrategyWithContent`\r\n- Add a benchmark to see the difference between using `Duplicator` and without it\r\n\r\nResult:\r\n- Better performance\r\n```\r\nBenchmark                 Mode  Cnt     Score      Error  Units\r\nWithDuplicator.empty     thrpt    5  7491.463 ±  497.119  ops/s\r\nWithoutDuplicator.empty  thrpt    5  8395.839 ± 2259.841  ops/s\r\n```\r\n- Close #1408\r\n\r\nTodo:\r\n- Change `FixedStreamMessage` duplicable\r\n- Don't let `RetryingHttpClient` use `HttpRequestDuplicator` when the content-length is zero","created_at":"2018-10-30T10:43:49Z","updated_at":"2018-11-07T03:53:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96292a0ab866f730fb28f654c9cdc11e522fe7ea","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":632570305,"node_id":"MDU6TGFiZWw2MzI1NzAzMDU=","url":"https://api.github.com/repos/line/armeria/labels/breaking-change","name":"breaking-change","color":"fc2929","default":false},{"id":287373881,"node_id":"MDU6TGFiZWwyODczNzM4ODE=","url":"https://api.github.com/repos/line/armeria/labels/new-feature","name":"new-feature","color":"009800","default":false},{"id":740346031,"node_id":"MDU6TGFiZWw3NDAzNDYwMzE=","url":"https://api.github.com/repos/line/armeria/labels/performance","name":"performance","color":"a7f9bd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/line/armeria/pulls/1418/commits","review_comments_url":"https://api.github.com/repos/line/armeria/pulls/1418/comments","review_comment_url":"https://api.github.com/repos/line/armeria/pulls/comments{/number}","comments_url":"https://api.github.com/repos/line/armeria/issues/1418/comments","statuses_url":"https://api.github.com/repos/line/armeria/statuses/7ab99157b7d727b42bc16cb66e1c63d9b1867ecc","head":{"label":"minwoox:remove_stream_duplicator","ref":"remove_stream_duplicator","sha":"7ab99157b7d727b42bc16cb66e1c63d9b1867ecc","user":{"login":"minwoox","id":25103250,"node_id":"MDQ6VXNlcjI1MTAzMjUw","avatar_url":"https://avatars2.githubusercontent.com/u/25103250?v=4","gravatar_id":"","url":"https://api.github.com/users/minwoox","html_url":"https://github.com/minwoox","followers_url":"https://api.github.com/users/minwoox/followers","following_url":"https://api.github.com/users/minwoox/following{/other_user}","gists_url":"https://api.github.com/users/minwoox/gists{/gist_id}","starred_url":"https://api.github.com/users/minwoox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minwoox/subscriptions","organizations_url":"https://api.github.com/users/minwoox/orgs","repos_url":"https://api.github.com/users/minwoox/repos","events_url":"https://api.github.com/users/minwoox/events{/privacy}","received_events_url":"https://api.github.com/users/minwoox/received_events","type":"User","site_admin":false},"repo":{"id":107944248,"node_id":"MDEwOlJlcG9zaXRvcnkxMDc5NDQyNDg=","name":"armeria","full_name":"minwoox/armeria","private":false,"owner":{"login":"minwoox","id":25103250,"node_id":"MDQ6VXNlcjI1MTAzMjUw","avatar_url":"https://avatars2.githubusercontent.com/u/25103250?v=4","gravatar_id":"","url":"https://api.github.com/users/minwoox","html_url":"https://github.com/minwoox","followers_url":"https://api.github.com/users/minwoox/followers","following_url":"https://api.github.com/users/minwoox/following{/other_user}","gists_url":"https://api.github.com/users/minwoox/gists{/gist_id}","starred_url":"https://api.github.com/users/minwoox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minwoox/subscriptions","organizations_url":"https://api.github.com/users/minwoox/orgs","repos_url":"https://api.github.com/users/minwoox/repos","events_url":"https://api.github.com/users/minwoox/events{/privacy}","received_events_url":"https://api.github.com/users/minwoox/received_events","type":"User","site_admin":false},"html_url":"https://github.com/minwoox/armeria","description":"Asynchronous RPC/REST library built on top of Java 8, Netty, HTTP/2, Thrift and gRPC","fork":true,"url":"https://api.github.com/repos/minwoox/armeria","forks_url":"https://api.github.com/repos/minwoox/armeria/forks","keys_url":"https://api.github.com/repos/minwoox/armeria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minwoox/armeria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minwoox/armeria/teams","hooks_url":"https://api.github.com/repos/minwoox/armeria/hooks","issue_events_url":"https://api.github.com/repos/minwoox/armeria/issues/events{/number}","events_url":"https://api.github.com/repos/minwoox/armeria/events","assignees_url":"https://api.github.com/repos/minwoox/armeria/assignees{/user}","branches_url":"https://api.github.com/repos/minwoox/armeria/branches{/branch}","tags_url":"https://api.github.com/repos/minwoox/armeria/tags","blobs_url":"https://api.github.com/repos/minwoox/armeria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minwoox/armeria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minwoox/armeria/git/refs{/sha}","trees_url":"https://api.github.com/repos/minwoox/armeria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minwoox/armeria/statuses/{sha}","languages_url":"https://api.github.com/repos/minwoox/armeria/languages","stargazers_url":"https://api.github.com/repos/minwoox/armeria/stargazers","contributors_url":"https://api.github.com/repos/minwoox/armeria/contributors","subscribers_url":"https://api.github.com/repos/minwoox/armeria/subscribers","subscription_url":"https://api.github.com/repos/minwoox/armeria/subscription","commits_url":"https://api.github.com/repos/minwoox/armeria/commits{/sha}","git_commits_url":"https://api.github.com/repos/minwoox/armeria/git/commits{/sha}","comments_url":"https://api.github.com/repos/minwoox/armeria/comments{/number}","issue_comment_url":"https://api.github.com/repos/minwoox/armeria/issues/comments{/number}","contents_url":"https://api.github.com/repos/minwoox/armeria/contents/{+path}","compare_url":"https://api.github.com/repos/minwoox/armeria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minwoox/armeria/merges","archive_url":"https://api.github.com/repos/minwoox/armeria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minwoox/armeria/downloads","issues_url":"https://api.github.com/repos/minwoox/armeria/issues{/number}","pulls_url":"https://api.github.com/repos/minwoox/armeria/pulls{/number}","milestones_url":"https://api.github.com/repos/minwoox/armeria/milestones{/number}","notifications_url":"https://api.github.com/repos/minwoox/armeria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minwoox/armeria/labels{/name}","releases_url":"https://api.github.com/repos/minwoox/armeria/releases{/id}","deployments_url":"https://api.github.com/repos/minwoox/armeria/deployments","created_at":"2017-10-23T07:04:32Z","updated_at":"2018-08-24T12:43:57Z","pushed_at":"2018-11-07T01:12:17Z","git_url":"git://github.com/minwoox/armeria.git","ssh_url":"git@github.com:minwoox/armeria.git","clone_url":"https://github.com/minwoox/armeria.git","svn_url":"https://github.com/minwoox/armeria","homepage":"http://line.github.io/armeria/","size":55567,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"line:master","ref":"master","sha":"a1d77d69797cbc2627ba56e319e84fcb0589d721","user":{"login":"line","id":13128444,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMTI4NDQ0","avatar_url":"https://avatars2.githubusercontent.com/u/13128444?v=4","gravatar_id":"","url":"https://api.github.com/users/line","html_url":"https://github.com/line","followers_url":"https://api.github.com/users/line/followers","following_url":"https://api.github.com/users/line/following{/other_user}","gists_url":"https://api.github.com/users/line/gists{/gist_id}","starred_url":"https://api.github.com/users/line/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/line/subscriptions","organizations_url":"https://api.github.com/users/line/orgs","repos_url":"https://api.github.com/users/line/repos","events_url":"https://api.github.com/users/line/events{/privacy}","received_events_url":"https://api.github.com/users/line/received_events","type":"Organization","site_admin":false},"repo":{"id":46251204,"node_id":"MDEwOlJlcG9zaXRvcnk0NjI1MTIwNA==","name":"armeria","full_name":"line/armeria","private":false,"owner":{"login":"line","id":13128444,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMTI4NDQ0","avatar_url":"https://avatars2.githubusercontent.com/u/13128444?v=4","gravatar_id":"","url":"https://api.github.com/users/line","html_url":"https://github.com/line","followers_url":"https://api.github.com/users/line/followers","following_url":"https://api.github.com/users/line/following{/other_user}","gists_url":"https://api.github.com/users/line/gists{/gist_id}","starred_url":"https://api.github.com/users/line/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/line/subscriptions","organizations_url":"https://api.github.com/users/line/orgs","repos_url":"https://api.github.com/users/line/repos","events_url":"https://api.github.com/users/line/events{/privacy}","received_events_url":"https://api.github.com/users/line/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/line/armeria","description":"Asynchronous RPC/REST library built on top of Java 8, Netty, HTTP/2, Thrift and gRPC","fork":false,"url":"https://api.github.com/repos/line/armeria","forks_url":"https://api.github.com/repos/line/armeria/forks","keys_url":"https://api.github.com/repos/line/armeria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/line/armeria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/line/armeria/teams","hooks_url":"https://api.github.com/repos/line/armeria/hooks","issue_events_url":"https://api.github.com/repos/line/armeria/issues/events{/number}","events_url":"https://api.github.com/repos/line/armeria/events","assignees_url":"https://api.github.com/repos/line/armeria/assignees{/user}","branches_url":"https://api.github.com/repos/line/armeria/branches{/branch}","tags_url":"https://api.github.com/repos/line/armeria/tags","blobs_url":"https://api.github.com/repos/line/armeria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/line/armeria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/line/armeria/git/refs{/sha}","trees_url":"https://api.github.com/repos/line/armeria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/line/armeria/statuses/{sha}","languages_url":"https://api.github.com/repos/line/armeria/languages","stargazers_url":"https://api.github.com/repos/line/armeria/stargazers","contributors_url":"https://api.github.com/repos/line/armeria/contributors","subscribers_url":"https://api.github.com/repos/line/armeria/subscribers","subscription_url":"https://api.github.com/repos/line/armeria/subscription","commits_url":"https://api.github.com/repos/line/armeria/commits{/sha}","git_commits_url":"https://api.github.com/repos/line/armeria/git/commits{/sha}","comments_url":"https://api.github.com/repos/line/armeria/comments{/number}","issue_comment_url":"https://api.github.com/repos/line/armeria/issues/comments{/number}","contents_url":"https://api.github.com/repos/line/armeria/contents/{+path}","compare_url":"https://api.github.com/repos/line/armeria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/line/armeria/merges","archive_url":"https://api.github.com/repos/line/armeria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/line/armeria/downloads","issues_url":"https://api.github.com/repos/line/armeria/issues{/number}","pulls_url":"https://api.github.com/repos/line/armeria/pulls{/number}","milestones_url":"https://api.github.com/repos/line/armeria/milestones{/number}","notifications_url":"https://api.github.com/repos/line/armeria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/line/armeria/labels{/name}","releases_url":"https://api.github.com/repos/line/armeria/releases{/id}","deployments_url":"https://api.github.com/repos/line/armeria/deployments","created_at":"2015-11-16T04:04:01Z","updated_at":"2018-11-07T02:03:58Z","pushed_at":"2018-11-07T01:12:19Z","git_url":"git://github.com/line/armeria.git","ssh_url":"git@github.com:line/armeria.git","clone_url":"https://github.com/line/armeria.git","svn_url":"https://github.com/line/armeria","homepage":"https://line.github.io/armeria/","size":56534,"stargazers_count":1471,"watchers_count":1471,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":317,"mirror_url":null,"archived":false,"open_issues_count":114,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":317,"open_issues":114,"watchers":1471,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/line/armeria/pulls/1418"},"html":{"href":"https://github.com/line/armeria/pull/1418"},"issue":{"href":"https://api.github.com/repos/line/armeria/issues/1418"},"comments":{"href":"https://api.github.com/repos/line/armeria/issues/1418/comments"},"review_comments":{"href":"https://api.github.com/repos/line/armeria/pulls/1418/comments"},"review_comment":{"href":"https://api.github.com/repos/line/armeria/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/line/armeria/pulls/1418/commits"},"statuses":{"href":"https://api.github.com/repos/line/armeria/statuses/7ab99157b7d727b42bc16cb66e1c63d9b1867ecc"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"trustin"}}