{"action":"created","comment":{"url":"https://api.github.com/repos/googleapis/gax-java/pulls/comments/155141588","pull_request_review_id":81410611,"id":155141588,"diff_hunk":"@@ -0,0 +1,131 @@\n+/*\n+ * Copyright 2017, Google LLC All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above\n+ * copyright notice, this list of conditions and the following disclaimer\n+ * in the documentation and/or other materials provided with the\n+ * distribution.\n+ *     * Neither the name of Google LLC nor the names of its\n+ * contributors may be used to endorse or promote products derived from\n+ * this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+package com.google.api.gax.grpc;\n+\n+import com.google.api.gax.rpc.ResponseObserver;\n+import com.google.api.gax.rpc.StreamController;\n+import com.google.common.base.Preconditions;\n+import io.grpc.ClientCall;\n+import io.grpc.Metadata;\n+import io.grpc.Status;\n+import java.util.concurrent.CancellationException;\n+\n+/**\n+ * Wraps a GRPC ClientCall in a {@link StreamController}. It feeds events to a {@link\n+ * ResponseObserver} and allows for back pressure.\n+ *\n+ * <p>Package-private for internal use.\n+ */\n+class GrpcDirectStreamController<RequestT, ResponseT> implements StreamController {","path":"gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcDirectStreamController.java","position":46,"original_position":46,"commit_id":"a05306c66bc4761e7d5f668541e4ddf53cc48d8b","original_commit_id":"a05306c66bc4761e7d5f668541e4ddf53cc48d8b","user":{"login":"pongad","id":1617025,"avatar_url":"https://avatars1.githubusercontent.com/u/1617025?v=4","gravatar_id":"","url":"https://api.github.com/users/pongad","html_url":"https://github.com/pongad","followers_url":"https://api.github.com/users/pongad/followers","following_url":"https://api.github.com/users/pongad/following{/other_user}","gists_url":"https://api.github.com/users/pongad/gists{/gist_id}","starred_url":"https://api.github.com/users/pongad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pongad/subscriptions","organizations_url":"https://api.github.com/users/pongad/orgs","repos_url":"https://api.github.com/users/pongad/repos","events_url":"https://api.github.com/users/pongad/events{/privacy}","received_events_url":"https://api.github.com/users/pongad/received_events","type":"User","site_admin":false},"body":"Should this class be thread-safe? Currently the bools and ints can race.","created_at":"2017-12-06T03:56:14Z","updated_at":"2017-12-06T04:00:46Z","html_url":"https://github.com/googleapis/gax-java/pull/437#discussion_r155141588","pull_request_url":"https://api.github.com/repos/googleapis/gax-java/pulls/437","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/comments/155141588"},"html":{"href":"https://github.com/googleapis/gax-java/pull/437#discussion_r155141588"},"pull_request":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/437"}}},"pull_request":{"url":"https://api.github.com/repos/googleapis/gax-java/pulls/437","id":155750146,"html_url":"https://github.com/googleapis/gax-java/pull/437","diff_url":"https://github.com/googleapis/gax-java/pull/437.diff","patch_url":"https://github.com/googleapis/gax-java/pull/437.patch","issue_url":"https://api.github.com/repos/googleapis/gax-java/issues/437","number":437,"state":"open","locked":false,"title":"back pressure: ResponseObserver & StreamController","user":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"body":"Introduces back pressure to gax's ServerStreamingCallables. This is part of #433\r\n\r\nApiStreamObserver gets upgraded to a ResponseObserver, which on stream start receives a StreamController. The StreamController allows the ResponseObserver to manually control flow. This inspired by reactive streams's api and grpc's ClientResponseObserver#beforeStart api:\r\nhttps://github.com/grpc/grpc-java/blob/master/stub/src/main/java/io/grpc/stub/ClientResponseObserver.java#L44\r\n\r\nThis api enables interoperability with other frameworks like RxJava & Akka and more importantly, allows for iterator style streams to be implemented on top of gax. This will, in turn, allow us to compose ServerStreamingCallables via call(Request, ResponseObserver, Context) chaining.\r\n\r\nThe external api is backwards compatible, but will break subclasses of ServerStreamCallable\r\n\r\nNext PRs: \r\n- implement the Iterable api: https://github.com/googleapis/gax-java/pull/433/commits/0832123bd1a58deedafb285bf838bcfc5d664db7\r\n- add a utility for reframing message streams: https://github.com/googleapis/gax-java/pull/433/commits/505b568beec626de3bafb0eeabf1c25e28c548cf\r\n","created_at":"2017-11-30T23:53:49Z","updated_at":"2017-12-06T04:00:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c23788bd6095524b5a4bea2b85544132a2c85dfa","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/googleapis/gax-java/pulls/437/commits","review_comments_url":"https://api.github.com/repos/googleapis/gax-java/pulls/437/comments","review_comment_url":"https://api.github.com/repos/googleapis/gax-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googleapis/gax-java/issues/437/comments","statuses_url":"https://api.github.com/repos/googleapis/gax-java/statuses/a05306c66bc4761e7d5f668541e4ddf53cc48d8b","head":{"label":"igorbernstein2:ssc-2-backpressure","ref":"ssc-2-backpressure","sha":"a05306c66bc4761e7d5f668541e4ddf53cc48d8b","user":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"repo":{"id":109061626,"name":"gax-java","full_name":"igorbernstein2/gax-java","owner":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/igorbernstein2/gax-java","description":"Google API Extensions for Java","fork":true,"url":"https://api.github.com/repos/igorbernstein2/gax-java","forks_url":"https://api.github.com/repos/igorbernstein2/gax-java/forks","keys_url":"https://api.github.com/repos/igorbernstein2/gax-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/igorbernstein2/gax-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/igorbernstein2/gax-java/teams","hooks_url":"https://api.github.com/repos/igorbernstein2/gax-java/hooks","issue_events_url":"https://api.github.com/repos/igorbernstein2/gax-java/issues/events{/number}","events_url":"https://api.github.com/repos/igorbernstein2/gax-java/events","assignees_url":"https://api.github.com/repos/igorbernstein2/gax-java/assignees{/user}","branches_url":"https://api.github.com/repos/igorbernstein2/gax-java/branches{/branch}","tags_url":"https://api.github.com/repos/igorbernstein2/gax-java/tags","blobs_url":"https://api.github.com/repos/igorbernstein2/gax-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/igorbernstein2/gax-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/igorbernstein2/gax-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/igorbernstein2/gax-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/igorbernstein2/gax-java/statuses/{sha}","languages_url":"https://api.github.com/repos/igorbernstein2/gax-java/languages","stargazers_url":"https://api.github.com/repos/igorbernstein2/gax-java/stargazers","contributors_url":"https://api.github.com/repos/igorbernstein2/gax-java/contributors","subscribers_url":"https://api.github.com/repos/igorbernstein2/gax-java/subscribers","subscription_url":"https://api.github.com/repos/igorbernstein2/gax-java/subscription","commits_url":"https://api.github.com/repos/igorbernstein2/gax-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/igorbernstein2/gax-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/igorbernstein2/gax-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/igorbernstein2/gax-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/igorbernstein2/gax-java/contents/{+path}","compare_url":"https://api.github.com/repos/igorbernstein2/gax-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/igorbernstein2/gax-java/merges","archive_url":"https://api.github.com/repos/igorbernstein2/gax-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/igorbernstein2/gax-java/downloads","issues_url":"https://api.github.com/repos/igorbernstein2/gax-java/issues{/number}","pulls_url":"https://api.github.com/repos/igorbernstein2/gax-java/pulls{/number}","milestones_url":"https://api.github.com/repos/igorbernstein2/gax-java/milestones{/number}","notifications_url":"https://api.github.com/repos/igorbernstein2/gax-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/igorbernstein2/gax-java/labels{/name}","releases_url":"https://api.github.com/repos/igorbernstein2/gax-java/releases{/id}","deployments_url":"https://api.github.com/repos/igorbernstein2/gax-java/deployments","created_at":"2017-10-31T23:07:12Z","updated_at":"2017-10-31T23:07:15Z","pushed_at":"2017-12-05T19:59:51Z","git_url":"git://github.com/igorbernstein2/gax-java.git","ssh_url":"git@github.com:igorbernstein2/gax-java.git","clone_url":"https://github.com/igorbernstein2/gax-java.git","svn_url":"https://github.com/igorbernstein2/gax-java","homepage":"","size":7964,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"googleapis:master","ref":"master","sha":"459a80af477ec727995f2df64f677c50dce2d983","user":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars3.githubusercontent.com/u/16785467?v=4","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"repo":{"id":50872805,"name":"gax-java","full_name":"googleapis/gax-java","owner":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars3.githubusercontent.com/u/16785467?v=4","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googleapis/gax-java","description":"Google API Extensions for Java","fork":false,"url":"https://api.github.com/repos/googleapis/gax-java","forks_url":"https://api.github.com/repos/googleapis/gax-java/forks","keys_url":"https://api.github.com/repos/googleapis/gax-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googleapis/gax-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googleapis/gax-java/teams","hooks_url":"https://api.github.com/repos/googleapis/gax-java/hooks","issue_events_url":"https://api.github.com/repos/googleapis/gax-java/issues/events{/number}","events_url":"https://api.github.com/repos/googleapis/gax-java/events","assignees_url":"https://api.github.com/repos/googleapis/gax-java/assignees{/user}","branches_url":"https://api.github.com/repos/googleapis/gax-java/branches{/branch}","tags_url":"https://api.github.com/repos/googleapis/gax-java/tags","blobs_url":"https://api.github.com/repos/googleapis/gax-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googleapis/gax-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googleapis/gax-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/googleapis/gax-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googleapis/gax-java/statuses/{sha}","languages_url":"https://api.github.com/repos/googleapis/gax-java/languages","stargazers_url":"https://api.github.com/repos/googleapis/gax-java/stargazers","contributors_url":"https://api.github.com/repos/googleapis/gax-java/contributors","subscribers_url":"https://api.github.com/repos/googleapis/gax-java/subscribers","subscription_url":"https://api.github.com/repos/googleapis/gax-java/subscription","commits_url":"https://api.github.com/repos/googleapis/gax-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/googleapis/gax-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/googleapis/gax-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/googleapis/gax-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/googleapis/gax-java/contents/{+path}","compare_url":"https://api.github.com/repos/googleapis/gax-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googleapis/gax-java/merges","archive_url":"https://api.github.com/repos/googleapis/gax-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googleapis/gax-java/downloads","issues_url":"https://api.github.com/repos/googleapis/gax-java/issues{/number}","pulls_url":"https://api.github.com/repos/googleapis/gax-java/pulls{/number}","milestones_url":"https://api.github.com/repos/googleapis/gax-java/milestones{/number}","notifications_url":"https://api.github.com/repos/googleapis/gax-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googleapis/gax-java/labels{/name}","releases_url":"https://api.github.com/repos/googleapis/gax-java/releases{/id}","deployments_url":"https://api.github.com/repos/googleapis/gax-java/deployments","created_at":"2016-02-01T21:33:22Z","updated_at":"2017-11-16T22:53:34Z","pushed_at":"2017-12-05T19:59:52Z","git_url":"git://github.com/googleapis/gax-java.git","ssh_url":"git@github.com:googleapis/gax-java.git","clone_url":"https://github.com/googleapis/gax-java.git","svn_url":"https://github.com/googleapis/gax-java","homepage":"","size":7849,"stargazers_count":18,"watchers_count":18,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":18,"open_issues":22,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/437"},"html":{"href":"https://github.com/googleapis/gax-java/pull/437"},"issue":{"href":"https://api.github.com/repos/googleapis/gax-java/issues/437"},"comments":{"href":"https://api.github.com/repos/googleapis/gax-java/issues/437/comments"},"review_comments":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/437/comments"},"review_comment":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googleapis/gax-java/pulls/437/commits"},"statuses":{"href":"https://api.github.com/repos/googleapis/gax-java/statuses/a05306c66bc4761e7d5f668541e4ddf53cc48d8b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pongad"}}