{"action":"created","comment":{"url":"https://api.github.com/repos/youtube/vitess/pulls/comments/36030714","id":36030714,"diff_hunk":"@@ -0,0 +1,138 @@\n+package com.youtube.vitess.client;\n+\n+import com.youtube.vitess.grpc.proto.Vtgate.BeginRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.BeginResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteBatchKeyspaceIdsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteBatchKeyspaceIdsResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteBatchShardsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteBatchShardsResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteKeyRangesRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteKeyRangesResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteKeyspaceIdsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteKeyspaceIdsResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteShardsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.ExecuteShardsResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.GetSrvKeyspaceRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.GetSrvKeyspaceResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteKeyRangesRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteKeyRangesResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteKeyspaceIdsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteKeyspaceIdsResponse;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteShardsRequest;\n+import com.youtube.vitess.grpc.proto.Vtgate.StreamExecuteShardsResponse;\n+\n+import java.io.Closeable;\n+import java.io.IOException;\n+import java.util.Iterator;\n+\n+/**\n+ * VTGateConn manages a VTGate connection.\n+ *\n+ * <p>Usage:\n+ *\n+ * <code>\n+ *   RpcClient client = RpcClientFactory.create(\n+ *     InetAddresses.forUriString(\"${VTGATE_ADDR}\", Duration.millis(500)));\n+ *   VTGateConn conn = VTGateConn.WithRpcClient(client);\n+ *   Context ctx = Context.withDeadline(DateTime.now().plusMillis(500));\n+ *\n+ *   try {\n+ *\n+ *       CallerID callerId = CallerID.newBuilder().setPrincipal(\"username\").build();\n+ *       BindVariable bindVars = BindVariable.newBuilder()\n+ *           .setType(Type.TYPE_INT)\n+ *           .setValueInt(12345)\n+ *           .build();\n+ *       BoundQuery.Builder queryBuilder = BoundQuery.newBuilder()\n+ *           .setSql(ByteString.copyFrom(\"INSERT INTO test_table VALUES(1, 2, 3)\", Charsets.UTF_8));\n+ *       queryBuilder.getMutableBindVariables().put(\"keyspaceid_01\", bindVars);\n+ *       BoundQuery query = queryBuilder.build();\n+ *       ExecuteKeyspaceIdsRequest.newBuilder()\n+ *           .setCallerId(callerId)\n+ *           .setQuery(query)\n+ *           .setKeyspace(\"my_keyspace\")\n+ *           .setKeyspaceIds(0, ByteString.copyFrom(\"keyspaceid_01\", Charsets.UTF_8))\n+ *           .setTabletType(TabletType.MASTER)\n+ *           .build();\n+ *\n+ *       ExecuteKeyspaceIdsResponse response = conn.ExecuteKeyspaceIds(ctx, request);\n+ *       if (response.hasError()) {\n+ *         // handle error.\n+ *       }\n+ *       QueryResult result = response.getResult();\n+ *       for (Row row : result.getRowsList()) {\n+ *         // process each row.\n+ *       }\n+ *  } catch (VitessRpcException e) {\n+ *     // ...\n+ *   }\n+ * </code>\n+ * */\n+public class VTGateConn implements Closeable {\n+\n+  private RpcClient client;\n+\n+  private VTGateConn(RpcClient client) { this.client = client; }\n+\n+  public static VTGateConn WithRpcClient(RpcClient client) {\n+    return new VTGateConn(client);\n+  }\n+\n+  public ExecuteShardsResponse ExecuteShard(Context ctx, ExecuteShardsRequest request)","path":"java/client/src/main/java/com/youtube/vitess/client/VTGateConn.java","position":81,"original_position":81,"commit_id":"8efa82b8a0ef1b045aeb9b31a4dabbf8a57f0b9c","original_commit_id":"8efa82b8a0ef1b045aeb9b31a4dabbf8a57f0b9c","user":{"login":"alainjobart","id":4625714,"avatar_url":"https://avatars.githubusercontent.com/u/4625714?v=3","gravatar_id":"","url":"https://api.github.com/users/alainjobart","html_url":"https://github.com/alainjobart","followers_url":"https://api.github.com/users/alainjobart/followers","following_url":"https://api.github.com/users/alainjobart/following{/other_user}","gists_url":"https://api.github.com/users/alainjobart/gists{/gist_id}","starred_url":"https://api.github.com/users/alainjobart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alainjobart/subscriptions","organizations_url":"https://api.github.com/users/alainjobart/orgs","repos_url":"https://api.github.com/users/alainjobart/repos","events_url":"https://api.github.com/users/alainjobart/events{/privacy}","received_events_url":"https://api.github.com/users/alainjobart/received_events","type":"User","site_admin":false},"body":"We need to define a VitessException for app-level errors and throw that. Like for integrity errors. It would have a code and a string.\r\n\r\nBut you can probably punt on that until Ammar has defined the error codes in a proto3 (and an error structure) and you can use them. Then in the gRPC implementation, you can plumb it in.\r\n\r\nSo for now, I would submit this in a form that works, and refactor it later (next week) for error codes.","created_at":"2015-08-01T05:02:54Z","updated_at":"2015-08-01T05:02:54Z","html_url":"https://github.com/youtube/vitess/pull/949#discussion_r36030714","pull_request_url":"https://api.github.com/repos/youtube/vitess/pulls/949","_links":{"self":{"href":"https://api.github.com/repos/youtube/vitess/pulls/comments/36030714"},"html":{"href":"https://github.com/youtube/vitess/pull/949#discussion_r36030714"},"pull_request":{"href":"https://api.github.com/repos/youtube/vitess/pulls/949"}}},"pull_request":{"url":"https://api.github.com/repos/youtube/vitess/pulls/949","id":41389546,"html_url":"https://github.com/youtube/vitess/pull/949","diff_url":"https://github.com/youtube/vitess/pull/949.diff","patch_url":"https://github.com/youtube/vitess/pull/949.patch","issue_url":"https://api.github.com/repos/youtube/vitess/issues/949","number":949,"state":"open","locked":false,"title":"add java client and grpc","user":{"login":"yaoshengzhe","id":626280,"avatar_url":"https://avatars.githubusercontent.com/u/626280?v=3","gravatar_id":"","url":"https://api.github.com/users/yaoshengzhe","html_url":"https://github.com/yaoshengzhe","followers_url":"https://api.github.com/users/yaoshengzhe/followers","following_url":"https://api.github.com/users/yaoshengzhe/following{/other_user}","gists_url":"https://api.github.com/users/yaoshengzhe/gists{/gist_id}","starred_url":"https://api.github.com/users/yaoshengzhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaoshengzhe/subscriptions","organizations_url":"https://api.github.com/users/yaoshengzhe/orgs","repos_url":"https://api.github.com/users/yaoshengzhe/repos","events_url":"https://api.github.com/users/yaoshengzhe/events{/privacy}","received_events_url":"https://api.github.com/users/yaoshengzhe/received_events","type":"User","site_admin":false},"body":"1. define rules in the Maven build files to compile the data protos at build time.\r\n2. define a new vtgate service interface that uses the proto3 data structures and\r\n   defines an abstract service.","created_at":"2015-07-31T23:14:41Z","updated_at":"2015-08-01T05:02:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88772e1e84336f782a5d4ea3c64b4b1e3d2db8ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/youtube/vitess/pulls/949/commits","review_comments_url":"https://api.github.com/repos/youtube/vitess/pulls/949/comments","review_comment_url":"https://api.github.com/repos/youtube/vitess/pulls/comments{/number}","comments_url":"https://api.github.com/repos/youtube/vitess/issues/949/comments","statuses_url":"https://api.github.com/repos/youtube/vitess/statuses/8efa82b8a0ef1b045aeb9b31a4dabbf8a57f0b9c","head":{"label":"yaoshengzhe:fix_java_grpc","ref":"fix_java_grpc","sha":"8efa82b8a0ef1b045aeb9b31a4dabbf8a57f0b9c","user":{"login":"yaoshengzhe","id":626280,"avatar_url":"https://avatars.githubusercontent.com/u/626280?v=3","gravatar_id":"","url":"https://api.github.com/users/yaoshengzhe","html_url":"https://github.com/yaoshengzhe","followers_url":"https://api.github.com/users/yaoshengzhe/followers","following_url":"https://api.github.com/users/yaoshengzhe/following{/other_user}","gists_url":"https://api.github.com/users/yaoshengzhe/gists{/gist_id}","starred_url":"https://api.github.com/users/yaoshengzhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaoshengzhe/subscriptions","organizations_url":"https://api.github.com/users/yaoshengzhe/orgs","repos_url":"https://api.github.com/users/yaoshengzhe/repos","events_url":"https://api.github.com/users/yaoshengzhe/events{/privacy}","received_events_url":"https://api.github.com/users/yaoshengzhe/received_events","type":"User","site_admin":false},"repo":{"id":27459467,"name":"vitess","full_name":"yaoshengzhe/vitess","owner":{"login":"yaoshengzhe","id":626280,"avatar_url":"https://avatars.githubusercontent.com/u/626280?v=3","gravatar_id":"","url":"https://api.github.com/users/yaoshengzhe","html_url":"https://github.com/yaoshengzhe","followers_url":"https://api.github.com/users/yaoshengzhe/followers","following_url":"https://api.github.com/users/yaoshengzhe/following{/other_user}","gists_url":"https://api.github.com/users/yaoshengzhe/gists{/gist_id}","starred_url":"https://api.github.com/users/yaoshengzhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaoshengzhe/subscriptions","organizations_url":"https://api.github.com/users/yaoshengzhe/orgs","repos_url":"https://api.github.com/users/yaoshengzhe/repos","events_url":"https://api.github.com/users/yaoshengzhe/events{/privacy}","received_events_url":"https://api.github.com/users/yaoshengzhe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yaoshengzhe/vitess","description":"vitess provides servers and tools which facilitate scaling of MySQL databases for large scale web services.","fork":true,"url":"https://api.github.com/repos/yaoshengzhe/vitess","forks_url":"https://api.github.com/repos/yaoshengzhe/vitess/forks","keys_url":"https://api.github.com/repos/yaoshengzhe/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yaoshengzhe/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yaoshengzhe/vitess/teams","hooks_url":"https://api.github.com/repos/yaoshengzhe/vitess/hooks","issue_events_url":"https://api.github.com/repos/yaoshengzhe/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/yaoshengzhe/vitess/events","assignees_url":"https://api.github.com/repos/yaoshengzhe/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/yaoshengzhe/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/yaoshengzhe/vitess/tags","blobs_url":"https://api.github.com/repos/yaoshengzhe/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yaoshengzhe/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yaoshengzhe/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/yaoshengzhe/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yaoshengzhe/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/yaoshengzhe/vitess/languages","stargazers_url":"https://api.github.com/repos/yaoshengzhe/vitess/stargazers","contributors_url":"https://api.github.com/repos/yaoshengzhe/vitess/contributors","subscribers_url":"https://api.github.com/repos/yaoshengzhe/vitess/subscribers","subscription_url":"https://api.github.com/repos/yaoshengzhe/vitess/subscription","commits_url":"https://api.github.com/repos/yaoshengzhe/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/yaoshengzhe/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/yaoshengzhe/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/yaoshengzhe/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/yaoshengzhe/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/yaoshengzhe/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yaoshengzhe/vitess/merges","archive_url":"https://api.github.com/repos/yaoshengzhe/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yaoshengzhe/vitess/downloads","issues_url":"https://api.github.com/repos/yaoshengzhe/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/yaoshengzhe/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/yaoshengzhe/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/yaoshengzhe/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yaoshengzhe/vitess/labels{/name}","releases_url":"https://api.github.com/repos/yaoshengzhe/vitess/releases{/id}","created_at":"2014-12-02T23:45:03Z","updated_at":"2015-05-07T18:03:02Z","pushed_at":"2015-08-01T04:45:56Z","git_url":"git://github.com/yaoshengzhe/vitess.git","ssh_url":"git@github.com:yaoshengzhe/vitess.git","clone_url":"https://github.com/yaoshengzhe/vitess.git","svn_url":"https://github.com/yaoshengzhe/vitess","homepage":null,"size":48326,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"youtube:master","ref":"master","sha":"9d19c16746878727b91c9aba9c7b41bf7b56b669","user":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"repo":{"id":11008207,"name":"vitess","full_name":"youtube/vitess","owner":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/youtube/vitess","description":"vitess provides servers and tools which facilitate scaling of MySQL databases for large scale web services.","fork":false,"url":"https://api.github.com/repos/youtube/vitess","forks_url":"https://api.github.com/repos/youtube/vitess/forks","keys_url":"https://api.github.com/repos/youtube/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/youtube/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/youtube/vitess/teams","hooks_url":"https://api.github.com/repos/youtube/vitess/hooks","issue_events_url":"https://api.github.com/repos/youtube/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/youtube/vitess/events","assignees_url":"https://api.github.com/repos/youtube/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/youtube/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/youtube/vitess/tags","blobs_url":"https://api.github.com/repos/youtube/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/youtube/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/youtube/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/youtube/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/youtube/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/youtube/vitess/languages","stargazers_url":"https://api.github.com/repos/youtube/vitess/stargazers","contributors_url":"https://api.github.com/repos/youtube/vitess/contributors","subscribers_url":"https://api.github.com/repos/youtube/vitess/subscribers","subscription_url":"https://api.github.com/repos/youtube/vitess/subscription","commits_url":"https://api.github.com/repos/youtube/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/youtube/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/youtube/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/youtube/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/youtube/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/youtube/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/youtube/vitess/merges","archive_url":"https://api.github.com/repos/youtube/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/youtube/vitess/downloads","issues_url":"https://api.github.com/repos/youtube/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/youtube/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/youtube/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/youtube/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/youtube/vitess/labels{/name}","releases_url":"https://api.github.com/repos/youtube/vitess/releases{/id}","created_at":"2013-06-27T21:20:28Z","updated_at":"2015-07-31T06:57:29Z","pushed_at":"2015-08-01T00:26:55Z","git_url":"git://github.com/youtube/vitess.git","ssh_url":"git@github.com:youtube/vitess.git","clone_url":"https://github.com/youtube/vitess.git","svn_url":"https://github.com/youtube/vitess","homepage":null,"size":68708,"stargazers_count":2672,"watchers_count":2672,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":334,"mirror_url":null,"open_issues_count":21,"forks":334,"open_issues":21,"watchers":2672,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/youtube/vitess/pulls/949"},"html":{"href":"https://github.com/youtube/vitess/pull/949"},"issue":{"href":"https://api.github.com/repos/youtube/vitess/issues/949"},"comments":{"href":"https://api.github.com/repos/youtube/vitess/issues/949/comments"},"review_comments":{"href":"https://api.github.com/repos/youtube/vitess/pulls/949/comments"},"review_comment":{"href":"https://api.github.com/repos/youtube/vitess/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/youtube/vitess/pulls/949/commits"},"statuses":{"href":"https://api.github.com/repos/youtube/vitess/statuses/8efa82b8a0ef1b045aeb9b31a4dabbf8a57f0b9c"}}}}