{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/comments/60328391","id":60328391,"diff_hunk":"@@ -0,0 +1,203 @@\n+/*\n+ * Copyright 2016 Google Inc. All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *       http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.google.cloud.pubsub;\n+\n+import com.google.cloud.AsyncPage;\n+import com.google.cloud.Page;\n+import com.google.cloud.Service;\n+\n+import java.io.Serializable;\n+import java.util.List;\n+import java.util.concurrent.Future;\n+import java.util.concurrent.TimeUnit;\n+\n+/**\n+ * An interface for Google Cloud Pub/Sub.\n+ *\n+ * @see <a href=\"https://cloud.google.com/pubsub/\">Google Cloud Pub/Sub</a>\n+ */\n+public interface PubSub extends Service<PubSubOptions> {\n+\n+  final class ListOption implements Serializable {\n+\n+    private static final long serialVersionUID = 6517442127283383124L;\n+\n+    private final Option option;\n+    private final Object value;\n+\n+    enum Option {\n+      PAGE_SIZE, PAGE_TOKEN\n+    }\n+\n+    private ListOption(Option option, Object value) {\n+      this.option = option;\n+      this.value = value;\n+    }\n+\n+    Option option() {\n+      return option;\n+    }\n+\n+    Object value() {\n+      return value;\n+    }\n+\n+    public static ListOption pageSize(int pageSize) {\n+      return new ListOption(Option.PAGE_SIZE, pageSize);\n+    }\n+\n+    public static ListOption pageToken(String pageToken) {\n+      return new ListOption(Option.PAGE_TOKEN, pageToken);\n+    }\n+  }\n+\n+  final class PullOption implements Serializable {\n+\n+    private static final long serialVersionUID = -5220474819637439937L;\n+\n+    private final Option option;\n+    private final Object value;\n+\n+    enum Option {\n+      RETURN_IMMEDIATELY, MAX_MESSAGES\n+    }\n+\n+    private PullOption(Option option, Object value) {\n+      this.option = option;\n+      this.value = value;\n+    }\n+\n+    Option option() {\n+      return option;\n+    }\n+\n+    Object value() {\n+      return value;\n+    }\n+\n+    public static PullOption returnImmediatly() {\n+      return new PullOption(Option.RETURN_IMMEDIATELY, true);\n+    }\n+\n+    public static PullOption maxMessages(int maxMessages) {\n+      return new PullOption(Option.MAX_MESSAGES, maxMessages);\n+    }\n+  }\n+\n+  /**\n+   * A callback to process pulled messages.\n+   * The message will be ack'ed upon successful return or nack'ed if exception is thrown.\n+   */\n+  interface PullCallback {\n+    void process(Message message) throws Exception;\n+  }\n+\n+  Topic create(TopicInfo topic);\n+\n+  Future<Topic> createAsync(TopicInfo topic);\n+\n+  // null if not found\n+  Topic getTopic(String topic);\n+\n+  Future<Topic> getTopicAsync(String topic);\n+\n+  // false if not found\n+  boolean deleteTopic(String topic);\n+\n+  Future<Boolean> deleteTopicAsync(String topic);\n+\n+  Page<Topic> listTopics(ListOption... options);\n+\n+  Future<AsyncPage<Topic>> listTopicsAsync(ListOption... options);\n+\n+  String publish(String topic, Message message);\n+\n+  Future<String> publishAsync(String topic, Message message);\n+\n+  List<String> publish(String topic, Message message, Message... messages);\n+\n+  Future<List<String>> publishAsync(String topic, Message message, Message... messages);\n+\n+  List<String> publish(String topic, Iterable<Message> messages);\n+\n+  Future<List<String>> publishAsync(String topic, Iterable<Message> messages);\n+\n+  Subscription create(SubscriptionInfo subscription);\n+\n+  Future<Subscription> createAsync(SubscriptionInfo subscription);\n+\n+  // null if not found\n+  Subscription getSubscription(String subscription);\n+\n+  Future<Subscription> getSubscriptionAsync(String subscription);\n+\n+  void replacePushConfig(String subscription, PushConfig pushConfig);\n+\n+  Future<Void> replacePushConfigAsync(String subscription, PushConfig pushConfig);\n+\n+  // false if not found\n+  boolean deleteSubscription(String subscription);\n+\n+  Future<Boolean> deleteSubscriptionAsync(String subscription);\n+\n+  Page<Subscription> listSubscriptions(ListOption... options);\n+\n+  Future<AsyncPage<Subscription>> listSubscriptionsAsync(ListOption... options);\n+\n+  Page<Subscription> listSubscriptions(String topic, ListOption... options);\n+\n+  Future<AsyncPage<Subscription>> listSubscriptionsAsync(String topic, ListOption... options);\n+\n+  List<ReceivedMessage> pull(String subscription, PullOption... options);\n+\n+  Future<List<ReceivedMessage>> pullAsync(String subscription, PullOption... options);\n+\n+  void pull(String subscription, PullCallback callback, PullOption... options);","path":"gcloud-java-pubsub/src/main/java/com/google/cloud/pubsub/PubSub.java","position":169,"original_position":169,"commit_id":"2d5f9dfad9a590cd4264127a7799297385df8b09","original_commit_id":"2d5f9dfad9a590cd4264127a7799297385df8b09","user":{"login":"aozarov","id":8921691,"avatar_url":"https://avatars.githubusercontent.com/u/8921691?v=3","gravatar_id":"","url":"https://api.github.com/users/aozarov","html_url":"https://github.com/aozarov","followers_url":"https://api.github.com/users/aozarov/followers","following_url":"https://api.github.com/users/aozarov/following{/other_user}","gists_url":"https://api.github.com/users/aozarov/gists{/gist_id}","starred_url":"https://api.github.com/users/aozarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aozarov/subscriptions","organizations_url":"https://api.github.com/users/aozarov/orgs","repos_url":"https://api.github.com/users/aozarov/repos","events_url":"https://api.github.com/users/aozarov/events{/privacy}","received_events_url":"https://api.github.com/users/aozarov/received_events","type":"User","site_admin":false},"body":"Yes, we should provide a way to stop pulling and probably not via PullOption.maxMessages.\r\n\r\nIn that case I suggest to only have one flavor (pulling is always async) and without supplying options (max-messages or runImmediately - I think the latter does not make sense at all in this mode). ","created_at":"2016-04-19T23:14:49Z","updated_at":"2016-04-19T23:14:49Z","html_url":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768#discussion_r60328391","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/comments/60328391"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768#discussion_r60328391"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768","id":63523885,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/768","number":768,"state":"open","locked":false,"title":"Pub/Sub API prototype","user":{"login":"aozarov","id":8921691,"avatar_url":"https://avatars.githubusercontent.com/u/8921691?v=3","gravatar_id":"","url":"https://api.github.com/users/aozarov","html_url":"https://github.com/aozarov","followers_url":"https://api.github.com/users/aozarov/followers","following_url":"https://api.github.com/users/aozarov/following{/other_user}","gists_url":"https://api.github.com/users/aozarov/gists{/gist_id}","starred_url":"https://api.github.com/users/aozarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aozarov/subscriptions","organizations_url":"https://api.github.com/users/aozarov/orgs","repos_url":"https://api.github.com/users/aozarov/repos","events_url":"https://api.github.com/users/aozarov/events{/privacy}","received_events_url":"https://api.github.com/users/aozarov/received_events","type":"User","site_admin":false},"body":"Creating this PR for API discussion only. *DO NOT merge*","created_at":"2016-03-21T05:46:42Z","updated_at":"2016-04-19T23:14:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2204415eefe68917348058045be474c732101ab6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/768/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/statuses/2d5f9dfad9a590cd4264127a7799297385df8b09","head":{"label":"aozarov:pubsub-alpha","ref":"pubsub-alpha","sha":"2d5f9dfad9a590cd4264127a7799297385df8b09","user":{"login":"aozarov","id":8921691,"avatar_url":"https://avatars.githubusercontent.com/u/8921691?v=3","gravatar_id":"","url":"https://api.github.com/users/aozarov","html_url":"https://github.com/aozarov","followers_url":"https://api.github.com/users/aozarov/followers","following_url":"https://api.github.com/users/aozarov/following{/other_user}","gists_url":"https://api.github.com/users/aozarov/gists{/gist_id}","starred_url":"https://api.github.com/users/aozarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aozarov/subscriptions","organizations_url":"https://api.github.com/users/aozarov/orgs","repos_url":"https://api.github.com/users/aozarov/repos","events_url":"https://api.github.com/users/aozarov/events{/privacy}","received_events_url":"https://api.github.com/users/aozarov/received_events","type":"User","site_admin":false},"repo":{"id":44983350,"name":"gcloud-java","full_name":"aozarov/gcloud-java","owner":{"login":"aozarov","id":8921691,"avatar_url":"https://avatars.githubusercontent.com/u/8921691?v=3","gravatar_id":"","url":"https://api.github.com/users/aozarov","html_url":"https://github.com/aozarov","followers_url":"https://api.github.com/users/aozarov/followers","following_url":"https://api.github.com/users/aozarov/following{/other_user}","gists_url":"https://api.github.com/users/aozarov/gists{/gist_id}","starred_url":"https://api.github.com/users/aozarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aozarov/subscriptions","organizations_url":"https://api.github.com/users/aozarov/orgs","repos_url":"https://api.github.com/users/aozarov/repos","events_url":"https://api.github.com/users/aozarov/events{/privacy}","received_events_url":"https://api.github.com/users/aozarov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aozarov/gcloud-java","description":"Google Cloud Client Library for Java","fork":true,"url":"https://api.github.com/repos/aozarov/gcloud-java","forks_url":"https://api.github.com/repos/aozarov/gcloud-java/forks","keys_url":"https://api.github.com/repos/aozarov/gcloud-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aozarov/gcloud-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aozarov/gcloud-java/teams","hooks_url":"https://api.github.com/repos/aozarov/gcloud-java/hooks","issue_events_url":"https://api.github.com/repos/aozarov/gcloud-java/issues/events{/number}","events_url":"https://api.github.com/repos/aozarov/gcloud-java/events","assignees_url":"https://api.github.com/repos/aozarov/gcloud-java/assignees{/user}","branches_url":"https://api.github.com/repos/aozarov/gcloud-java/branches{/branch}","tags_url":"https://api.github.com/repos/aozarov/gcloud-java/tags","blobs_url":"https://api.github.com/repos/aozarov/gcloud-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aozarov/gcloud-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aozarov/gcloud-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/aozarov/gcloud-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aozarov/gcloud-java/statuses/{sha}","languages_url":"https://api.github.com/repos/aozarov/gcloud-java/languages","stargazers_url":"https://api.github.com/repos/aozarov/gcloud-java/stargazers","contributors_url":"https://api.github.com/repos/aozarov/gcloud-java/contributors","subscribers_url":"https://api.github.com/repos/aozarov/gcloud-java/subscribers","subscription_url":"https://api.github.com/repos/aozarov/gcloud-java/subscription","commits_url":"https://api.github.com/repos/aozarov/gcloud-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/aozarov/gcloud-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/aozarov/gcloud-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/aozarov/gcloud-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/aozarov/gcloud-java/contents/{+path}","compare_url":"https://api.github.com/repos/aozarov/gcloud-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aozarov/gcloud-java/merges","archive_url":"https://api.github.com/repos/aozarov/gcloud-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aozarov/gcloud-java/downloads","issues_url":"https://api.github.com/repos/aozarov/gcloud-java/issues{/number}","pulls_url":"https://api.github.com/repos/aozarov/gcloud-java/pulls{/number}","milestones_url":"https://api.github.com/repos/aozarov/gcloud-java/milestones{/number}","notifications_url":"https://api.github.com/repos/aozarov/gcloud-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aozarov/gcloud-java/labels{/name}","releases_url":"https://api.github.com/repos/aozarov/gcloud-java/releases{/id}","deployments_url":"https://api.github.com/repos/aozarov/gcloud-java/deployments","created_at":"2015-10-26T16:53:21Z","updated_at":"2016-01-15T16:28:53Z","pushed_at":"2016-04-18T17:30:12Z","git_url":"git://github.com/aozarov/gcloud-java.git","ssh_url":"git@github.com:aozarov/gcloud-java.git","clone_url":"https://github.com/aozarov/gcloud-java.git","svn_url":"https://github.com/aozarov/gcloud-java","homepage":"http://googlecloudplatform.github.io/gcloud-java/","size":21416,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"GoogleCloudPlatform:pubsub-alpha","ref":"pubsub-alpha","sha":"9a64e635d79a1c3f722be0c184709b5e52b1d1b4","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":26181278,"name":"gcloud-java","full_name":"GoogleCloudPlatform/gcloud-java","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-java","description":"Google Cloud Client Library for Java","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/deployments","created_at":"2014-11-04T17:57:16Z","updated_at":"2016-04-16T14:36:21Z","pushed_at":"2016-04-19T20:56:54Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-java.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-java.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-java.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-java","homepage":"http://googlecloudplatform.github.io/gcloud-java/","size":224180,"stargazers_count":89,"watchers_count":89,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":47,"mirror_url":null,"open_issues_count":145,"forks":47,"open_issues":145,"watchers":89,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-java/pull/768"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/768"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/issues/768/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/pulls/768/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-java/statuses/2d5f9dfad9a590cd4264127a7799297385df8b09"}}}}