{"action":"created","comment":{"url":"https://api.github.com/repos/zalando/nakadi/pulls/comments/52157843","id":52157843,"diff_hunk":"@@ -0,0 +1,167 @@\n+package de.zalando.aruha.nakadi.controller;\n+\n+import com.codahale.metrics.annotation.Timed;\n+import com.fasterxml.jackson.core.type.TypeReference;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import de.zalando.aruha.nakadi.NakadiException;\n+import de.zalando.aruha.nakadi.domain.Cursor;\n+import de.zalando.aruha.nakadi.repository.EventConsumer;\n+import de.zalando.aruha.nakadi.repository.TopicRepository;\n+import de.zalando.aruha.nakadi.service.EventStream;\n+import de.zalando.aruha.nakadi.service.EventStreamConfig;\n+import de.zalando.aruha.nakadi.utils.FlushableGZIPOutputStream;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import org.springframework.http.HttpStatus;\n+import org.springframework.web.bind.annotation.PathVariable;\n+import org.springframework.web.bind.annotation.RequestHeader;\n+import org.springframework.web.bind.annotation.RequestMapping;\n+import org.springframework.web.bind.annotation.RequestMethod;\n+import org.springframework.web.bind.annotation.RequestParam;\n+import org.springframework.web.bind.annotation.RestController;\n+import org.springframework.web.context.request.NativeWebRequest;\n+import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;\n+import org.zalando.problem.Problem;\n+\n+import javax.annotation.Nullable;\n+import javax.servlet.http.HttpServletResponse;\n+import javax.ws.rs.core.Response;\n+import java.io.IOException;\n+import java.io.OutputStream;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;\n+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;\n+import static javax.ws.rs.core.Response.Status.NOT_FOUND;\n+import static javax.ws.rs.core.Response.Status.PRECONDITION_FAILED;\n+import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE;\n+import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY;\n+\n+@RestController\n+public class EventStreamController {\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(EventStreamController.class);\n+\n+    private final TopicRepository topicRepository;\n+\n+    private final ObjectMapper jsonMapper;\n+\n+    public EventStreamController(final TopicRepository topicRepository, final ObjectMapper jsonMapper) {\n+        this.topicRepository = topicRepository;\n+        this.jsonMapper = jsonMapper;\n+    }\n+\n+    @Timed(name = \"stream_events_for_event_type\", absolute = true)\n+    @RequestMapping(value = \"/event-types/{name}/events\", method = RequestMethod.GET)\n+    public StreamingResponseBody streamEventsFromPartition(\n+            @PathVariable(\"name\") final String eventTypeName,\n+            @RequestParam(value = \"batch_limit\", required = false, defaultValue = \"1\") final int batchLimit,\n+            @RequestParam(value = \"stream_limit\", required = false, defaultValue = \"0\") final int streamLimit,\n+            @RequestParam(value = \"batch_flush_timeout\", required = false, defaultValue = \"30\") final int batchTimeout,\n+            @RequestParam(value = \"stream_timeout\", required = false, defaultValue = \"0\") final int streamTimeout,\n+            @RequestParam(value = \"stream_keep_alive_limit\", required = false, defaultValue = \"0\") final int streamKeepAliveLimit,\n+            @Nullable @RequestHeader(name = \"X-nakadi-cursors\", required = false) final String cursorsStr,\n+            final NativeWebRequest request, final HttpServletResponse response) throws IOException {\n+\n+        return outputStream -> {\n+            try {\n+                // todo: we should get topic from EventType after persistence of EventType is implemented","path":"src/main/java/de/zalando/aruha/nakadi/controller/EventStreamController.java","position":71,"original_position":71,"commit_id":"384ad262b9f86e095001a6c057cf03457ef0844e","original_commit_id":"f70b2ab1c2b70103cc355de7c62cf60015da8343","user":{"login":"v-stepanov","id":13309177,"avatar_url":"https://avatars.githubusercontent.com/u/13309177?v=3","gravatar_id":"","url":"https://api.github.com/users/v-stepanov","html_url":"https://github.com/v-stepanov","followers_url":"https://api.github.com/users/v-stepanov/followers","following_url":"https://api.github.com/users/v-stepanov/following{/other_user}","gists_url":"https://api.github.com/users/v-stepanov/gists{/gist_id}","starred_url":"https://api.github.com/users/v-stepanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v-stepanov/subscriptions","organizations_url":"https://api.github.com/users/v-stepanov/orgs","repos_url":"https://api.github.com/users/v-stepanov/repos","events_url":"https://api.github.com/users/v-stepanov/events{/privacy}","received_events_url":"https://api.github.com/users/v-stepanov/received_events","type":"User","site_admin":false},"body":"1:1 is also fine for me. But since that is an open question I will keep the todo's.","created_at":"2016-02-08T11:25:34Z","updated_at":"2016-02-08T11:25:34Z","html_url":"https://github.com/zalando/nakadi/pull/81#discussion_r52157843","pull_request_url":"https://api.github.com/repos/zalando/nakadi/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/comments/52157843"},"html":{"href":"https://github.com/zalando/nakadi/pull/81#discussion_r52157843"},"pull_request":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/zalando/nakadi/pulls/81","id":57870379,"html_url":"https://github.com/zalando/nakadi/pull/81","diff_url":"https://github.com/zalando/nakadi/pull/81.diff","patch_url":"https://github.com/zalando/nakadi/pull/81.patch","issue_url":"https://api.github.com/repos/zalando/nakadi/issues/81","number":81,"state":"open","locked":false,"title":"Aruha 78 read streams","user":{"login":"v-stepanov","id":13309177,"avatar_url":"https://avatars.githubusercontent.com/u/13309177?v=3","gravatar_id":"","url":"https://api.github.com/users/v-stepanov","html_url":"https://github.com/v-stepanov","followers_url":"https://api.github.com/users/v-stepanov/followers","following_url":"https://api.github.com/users/v-stepanov/following{/other_user}","gists_url":"https://api.github.com/users/v-stepanov/gists{/gist_id}","starred_url":"https://api.github.com/users/v-stepanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v-stepanov/subscriptions","organizations_url":"https://api.github.com/users/v-stepanov/orgs","repos_url":"https://api.github.com/users/v-stepanov/repos","events_url":"https://api.github.com/users/v-stepanov/events{/privacy}","received_events_url":"https://api.github.com/users/v-stepanov/received_events","type":"User","site_admin":false},"body":"@tmuehl @rcillo @CyberDem0n @jkliff @valgog \r\nPlease take a look. It is an updated streaming and tests for streaming; actually quite a lot of things needed to be changed to align with latest API.\r\nThe only thing that is not there is the exclusive offsets. I faced a problem with that, which I would like to discuss when @jkliff and @valgog are back. So I will deliver (or not) that as a separate ticket/PR.","created_at":"2016-02-01T17:17:22Z","updated_at":"2016-02-08T11:25:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed27e89277b79eab6a663c1edddd123531b8de28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zalando/nakadi/pulls/81/commits","review_comments_url":"https://api.github.com/repos/zalando/nakadi/pulls/81/comments","review_comment_url":"https://api.github.com/repos/zalando/nakadi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zalando/nakadi/issues/81/comments","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/384ad262b9f86e095001a6c057cf03457ef0844e","head":{"label":"zalando:ARUHA-78-read-streams","ref":"ARUHA-78-read-streams","sha":"384ad262b9f86e095001a6c057cf03457ef0844e","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":44234368,"name":"nakadi","full_name":"zalando/nakadi","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/nakadi","description":"Zalando Distributed Event Bus","fork":false,"url":"https://api.github.com/repos/zalando/nakadi","forks_url":"https://api.github.com/repos/zalando/nakadi/forks","keys_url":"https://api.github.com/repos/zalando/nakadi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/nakadi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/nakadi/teams","hooks_url":"https://api.github.com/repos/zalando/nakadi/hooks","issue_events_url":"https://api.github.com/repos/zalando/nakadi/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/nakadi/events","assignees_url":"https://api.github.com/repos/zalando/nakadi/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/nakadi/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/nakadi/tags","blobs_url":"https://api.github.com/repos/zalando/nakadi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/nakadi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/nakadi/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/nakadi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/nakadi/languages","stargazers_url":"https://api.github.com/repos/zalando/nakadi/stargazers","contributors_url":"https://api.github.com/repos/zalando/nakadi/contributors","subscribers_url":"https://api.github.com/repos/zalando/nakadi/subscribers","subscription_url":"https://api.github.com/repos/zalando/nakadi/subscription","commits_url":"https://api.github.com/repos/zalando/nakadi/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/nakadi/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/nakadi/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/nakadi/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/nakadi/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/nakadi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/nakadi/merges","archive_url":"https://api.github.com/repos/zalando/nakadi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/nakadi/downloads","issues_url":"https://api.github.com/repos/zalando/nakadi/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/nakadi/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/nakadi/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/nakadi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/nakadi/labels{/name}","releases_url":"https://api.github.com/repos/zalando/nakadi/releases{/id}","deployments_url":"https://api.github.com/repos/zalando/nakadi/deployments","created_at":"2015-10-14T08:30:17Z","updated_at":"2016-01-21T14:51:44Z","pushed_at":"2016-02-08T11:19:30Z","git_url":"git://github.com/zalando/nakadi.git","ssh_url":"git@github.com:zalando/nakadi.git","clone_url":"https://github.com/zalando/nakadi.git","svn_url":"https://github.com/zalando/nakadi","homepage":"","size":724,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":10,"forks":7,"open_issues":10,"watchers":3,"default_branch":"nakadi-jvm"}},"base":{"label":"zalando:nakadi-jvm","ref":"nakadi-jvm","sha":"a004b4fc25b60dfee16cd51d4fea697d22e8e595","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":44234368,"name":"nakadi","full_name":"zalando/nakadi","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/nakadi","description":"Zalando Distributed Event Bus","fork":false,"url":"https://api.github.com/repos/zalando/nakadi","forks_url":"https://api.github.com/repos/zalando/nakadi/forks","keys_url":"https://api.github.com/repos/zalando/nakadi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/nakadi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/nakadi/teams","hooks_url":"https://api.github.com/repos/zalando/nakadi/hooks","issue_events_url":"https://api.github.com/repos/zalando/nakadi/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/nakadi/events","assignees_url":"https://api.github.com/repos/zalando/nakadi/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/nakadi/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/nakadi/tags","blobs_url":"https://api.github.com/repos/zalando/nakadi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/nakadi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/nakadi/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/nakadi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/nakadi/languages","stargazers_url":"https://api.github.com/repos/zalando/nakadi/stargazers","contributors_url":"https://api.github.com/repos/zalando/nakadi/contributors","subscribers_url":"https://api.github.com/repos/zalando/nakadi/subscribers","subscription_url":"https://api.github.com/repos/zalando/nakadi/subscription","commits_url":"https://api.github.com/repos/zalando/nakadi/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/nakadi/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/nakadi/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/nakadi/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/nakadi/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/nakadi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/nakadi/merges","archive_url":"https://api.github.com/repos/zalando/nakadi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/nakadi/downloads","issues_url":"https://api.github.com/repos/zalando/nakadi/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/nakadi/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/nakadi/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/nakadi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/nakadi/labels{/name}","releases_url":"https://api.github.com/repos/zalando/nakadi/releases{/id}","deployments_url":"https://api.github.com/repos/zalando/nakadi/deployments","created_at":"2015-10-14T08:30:17Z","updated_at":"2016-01-21T14:51:44Z","pushed_at":"2016-02-08T11:19:30Z","git_url":"git://github.com/zalando/nakadi.git","ssh_url":"git@github.com:zalando/nakadi.git","clone_url":"https://github.com/zalando/nakadi.git","svn_url":"https://github.com/zalando/nakadi","homepage":"","size":724,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":10,"forks":7,"open_issues":10,"watchers":3,"default_branch":"nakadi-jvm"}},"_links":{"self":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/81"},"html":{"href":"https://github.com/zalando/nakadi/pull/81"},"issue":{"href":"https://api.github.com/repos/zalando/nakadi/issues/81"},"comments":{"href":"https://api.github.com/repos/zalando/nakadi/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/zalando/nakadi/statuses/384ad262b9f86e095001a6c057cf03457ef0844e"}}}}