{"action":"created","comment":{"url":"https://api.github.com/repos/cookpad/streamy/pulls/comments/197644736","pull_request_review_id":131428429,"id":197644736,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzY0NDczNg==","diff_hunk":"@@ -32,6 +29,14 @@ module Streamy\n \n   class << self\n     attr_accessor :message_bus, :worker, :logger, :cache\n+\n+    def shutdown\n+      message_bus.shutdown if message_bus.respond_to? :shutdown\n+    end\n+\n+    def deliver_events\n+      message_bus.deliver_events if message_bus.respond_to? :deliver_events","path":"lib/streamy.rb","position":20,"original_position":20,"commit_id":"932f16e427b93abe32862fd4b295d9c4e6e85c94","original_commit_id":"932f16e427b93abe32862fd4b295d9c4e6e85c94","user":{"login":"lewispb","id":1773614,"node_id":"MDQ6VXNlcjE3NzM2MTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1773614?v=4","gravatar_id":"","url":"https://api.github.com/users/lewispb","html_url":"https://github.com/lewispb","followers_url":"https://api.github.com/users/lewispb/followers","following_url":"https://api.github.com/users/lewispb/following{/other_user}","gists_url":"https://api.github.com/users/lewispb/gists{/gist_id}","starred_url":"https://api.github.com/users/lewispb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewispb/subscriptions","organizations_url":"https://api.github.com/users/lewispb/orgs","repos_url":"https://api.github.com/users/lewispb/repos","events_url":"https://api.github.com/users/lewispb/events{/privacy}","received_events_url":"https://api.github.com/users/lewispb/received_events","type":"User","site_admin":false},"body":"`message_bus.try(:deliver_events)` ?","created_at":"2018-06-24T16:07:34Z","updated_at":"2018-06-24T16:32:33Z","html_url":"https://github.com/cookpad/streamy/pull/51#discussion_r197644736","pull_request_url":"https://api.github.com/repos/cookpad/streamy/pulls/51","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/comments/197644736"},"html":{"href":"https://github.com/cookpad/streamy/pull/51#discussion_r197644736"},"pull_request":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/cookpad/streamy/pulls/51","id":196764971,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NzY0OTcx","html_url":"https://github.com/cookpad/streamy/pull/51","diff_url":"https://github.com/cookpad/streamy/pull/51.diff","patch_url":"https://github.com/cookpad/streamy/pull/51.patch","issue_url":"https://api.github.com/repos/cookpad/streamy/issues/51","number":51,"state":"open","locked":false,"title":"Kafka, support different message sending priorities ...","user":{"login":"errm","id":115280,"node_id":"MDQ6VXNlcjExNTI4MA==","avatar_url":"https://avatars2.githubusercontent.com/u/115280?v=4","gravatar_id":"","url":"https://api.github.com/users/errm","html_url":"https://github.com/errm","followers_url":"https://api.github.com/users/errm/followers","following_url":"https://api.github.com/users/errm/following{/other_user}","gists_url":"https://api.github.com/users/errm/gists{/gist_id}","starred_url":"https://api.github.com/users/errm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/errm/subscriptions","organizations_url":"https://api.github.com/users/errm/orgs","repos_url":"https://api.github.com/users/errm/repos","events_url":"https://api.github.com/users/errm/events{/privacy}","received_events_url":"https://api.github.com/users/errm/received_events","type":"User","site_admin":false},"body":"During our load test with Kafka we were slightly concerned that there were some performance issues when sending messages to Kafka within the response cycle.\r\n\r\n`ruby-kafka` has quite a complete API for producing messages, that allow for several different semantics to be observed.\r\n\r\nIn order to make this somewhat useable within our applications I have introduced the concept of priorities to the event... This is just a method on the Event class, and is defaulted to `:standard`, other priorities can be used by overriding the method in your event class, (indeed it would even be possible to have the event class dynamically decide what priority each instance should have).\r\n\r\n`:low` priority events are the most risky as are buffered and sent in batches in the background, if the process crashes between calling publish and the batch being ready to publish then it is lost forever ... if there is a Kafka outage, then messages will be retried... but ultimately could be lost if the outage lasts a long time.\r\n\r\n`:standard` priority events are a bit less risky becuase we signal the background thread to initiate the send straight away ... In an outage publish would still return without error and we would rely on the background thread to retry.\r\n\r\n`:essential` events are sent straight away in the current thread... the call to `publish` blocks until the message is sent and any error with sending the message is thrown... This is ideal where we want to be 100% sure an event is persisted before returning to the user ... I guess events like publishing a recipe etc might fall into this category...\r\n\r\n`:manual` events are intended to be used when we want to manually control the batching of events, events are buffered and not sent until `Streamy.deliver_events` is called ... This seems useful whenever we want to send several events at once... ","created_at":"2018-06-22T15:04:36Z","updated_at":"2018-06-24T16:32:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2d568360b877f5e98118d1a6f36b25465044187","assignee":null,"assignees":[],"requested_reviewers":[{"login":"balvig","id":104138,"node_id":"MDQ6VXNlcjEwNDEzOA==","avatar_url":"https://avatars0.githubusercontent.com/u/104138?v=4","gravatar_id":"","url":"https://api.github.com/users/balvig","html_url":"https://github.com/balvig","followers_url":"https://api.github.com/users/balvig/followers","following_url":"https://api.github.com/users/balvig/following{/other_user}","gists_url":"https://api.github.com/users/balvig/gists{/gist_id}","starred_url":"https://api.github.com/users/balvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balvig/subscriptions","organizations_url":"https://api.github.com/users/balvig/orgs","repos_url":"https://api.github.com/users/balvig/repos","events_url":"https://api.github.com/users/balvig/events{/privacy}","received_events_url":"https://api.github.com/users/balvig/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cookpad/streamy/pulls/51/commits","review_comments_url":"https://api.github.com/repos/cookpad/streamy/pulls/51/comments","review_comment_url":"https://api.github.com/repos/cookpad/streamy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cookpad/streamy/issues/51/comments","statuses_url":"https://api.github.com/repos/cookpad/streamy/statuses/932f16e427b93abe32862fd4b295d9c4e6e85c94","head":{"label":"cookpad:support-different-kafka-producers","ref":"support-different-kafka-producers","sha":"932f16e427b93abe32862fd4b295d9c4e6e85c94","user":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"repo":{"id":88128142,"node_id":"MDEwOlJlcG9zaXRvcnk4ODEyODE0Mg==","name":"streamy","full_name":"cookpad/streamy","owner":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cookpad/streamy","description":"Basic toolset for hooking into event stream","fork":false,"url":"https://api.github.com/repos/cookpad/streamy","forks_url":"https://api.github.com/repos/cookpad/streamy/forks","keys_url":"https://api.github.com/repos/cookpad/streamy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cookpad/streamy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cookpad/streamy/teams","hooks_url":"https://api.github.com/repos/cookpad/streamy/hooks","issue_events_url":"https://api.github.com/repos/cookpad/streamy/issues/events{/number}","events_url":"https://api.github.com/repos/cookpad/streamy/events","assignees_url":"https://api.github.com/repos/cookpad/streamy/assignees{/user}","branches_url":"https://api.github.com/repos/cookpad/streamy/branches{/branch}","tags_url":"https://api.github.com/repos/cookpad/streamy/tags","blobs_url":"https://api.github.com/repos/cookpad/streamy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cookpad/streamy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cookpad/streamy/git/refs{/sha}","trees_url":"https://api.github.com/repos/cookpad/streamy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cookpad/streamy/statuses/{sha}","languages_url":"https://api.github.com/repos/cookpad/streamy/languages","stargazers_url":"https://api.github.com/repos/cookpad/streamy/stargazers","contributors_url":"https://api.github.com/repos/cookpad/streamy/contributors","subscribers_url":"https://api.github.com/repos/cookpad/streamy/subscribers","subscription_url":"https://api.github.com/repos/cookpad/streamy/subscription","commits_url":"https://api.github.com/repos/cookpad/streamy/commits{/sha}","git_commits_url":"https://api.github.com/repos/cookpad/streamy/git/commits{/sha}","comments_url":"https://api.github.com/repos/cookpad/streamy/comments{/number}","issue_comment_url":"https://api.github.com/repos/cookpad/streamy/issues/comments{/number}","contents_url":"https://api.github.com/repos/cookpad/streamy/contents/{+path}","compare_url":"https://api.github.com/repos/cookpad/streamy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cookpad/streamy/merges","archive_url":"https://api.github.com/repos/cookpad/streamy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cookpad/streamy/downloads","issues_url":"https://api.github.com/repos/cookpad/streamy/issues{/number}","pulls_url":"https://api.github.com/repos/cookpad/streamy/pulls{/number}","milestones_url":"https://api.github.com/repos/cookpad/streamy/milestones{/number}","notifications_url":"https://api.github.com/repos/cookpad/streamy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cookpad/streamy/labels{/name}","releases_url":"https://api.github.com/repos/cookpad/streamy/releases{/id}","deployments_url":"https://api.github.com/repos/cookpad/streamy/deployments","created_at":"2017-04-13T05:26:26Z","updated_at":"2018-06-13T00:17:10Z","pushed_at":"2018-06-24T01:09:08Z","git_url":"git://github.com/cookpad/streamy.git","ssh_url":"git@github.com:cookpad/streamy.git","clone_url":"https://github.com/cookpad/streamy.git","svn_url":"https://github.com/cookpad/streamy","homepage":null,"size":153,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":4,"watchers":6,"default_branch":"master"}},"base":{"label":"cookpad:master","ref":"master","sha":"e467d1b786c8acc1eb464def2e46a410f1b1f603","user":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"repo":{"id":88128142,"node_id":"MDEwOlJlcG9zaXRvcnk4ODEyODE0Mg==","name":"streamy","full_name":"cookpad/streamy","owner":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cookpad/streamy","description":"Basic toolset for hooking into event stream","fork":false,"url":"https://api.github.com/repos/cookpad/streamy","forks_url":"https://api.github.com/repos/cookpad/streamy/forks","keys_url":"https://api.github.com/repos/cookpad/streamy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cookpad/streamy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cookpad/streamy/teams","hooks_url":"https://api.github.com/repos/cookpad/streamy/hooks","issue_events_url":"https://api.github.com/repos/cookpad/streamy/issues/events{/number}","events_url":"https://api.github.com/repos/cookpad/streamy/events","assignees_url":"https://api.github.com/repos/cookpad/streamy/assignees{/user}","branches_url":"https://api.github.com/repos/cookpad/streamy/branches{/branch}","tags_url":"https://api.github.com/repos/cookpad/streamy/tags","blobs_url":"https://api.github.com/repos/cookpad/streamy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cookpad/streamy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cookpad/streamy/git/refs{/sha}","trees_url":"https://api.github.com/repos/cookpad/streamy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cookpad/streamy/statuses/{sha}","languages_url":"https://api.github.com/repos/cookpad/streamy/languages","stargazers_url":"https://api.github.com/repos/cookpad/streamy/stargazers","contributors_url":"https://api.github.com/repos/cookpad/streamy/contributors","subscribers_url":"https://api.github.com/repos/cookpad/streamy/subscribers","subscription_url":"https://api.github.com/repos/cookpad/streamy/subscription","commits_url":"https://api.github.com/repos/cookpad/streamy/commits{/sha}","git_commits_url":"https://api.github.com/repos/cookpad/streamy/git/commits{/sha}","comments_url":"https://api.github.com/repos/cookpad/streamy/comments{/number}","issue_comment_url":"https://api.github.com/repos/cookpad/streamy/issues/comments{/number}","contents_url":"https://api.github.com/repos/cookpad/streamy/contents/{+path}","compare_url":"https://api.github.com/repos/cookpad/streamy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cookpad/streamy/merges","archive_url":"https://api.github.com/repos/cookpad/streamy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cookpad/streamy/downloads","issues_url":"https://api.github.com/repos/cookpad/streamy/issues{/number}","pulls_url":"https://api.github.com/repos/cookpad/streamy/pulls{/number}","milestones_url":"https://api.github.com/repos/cookpad/streamy/milestones{/number}","notifications_url":"https://api.github.com/repos/cookpad/streamy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cookpad/streamy/labels{/name}","releases_url":"https://api.github.com/repos/cookpad/streamy/releases{/id}","deployments_url":"https://api.github.com/repos/cookpad/streamy/deployments","created_at":"2017-04-13T05:26:26Z","updated_at":"2018-06-13T00:17:10Z","pushed_at":"2018-06-24T01:09:08Z","git_url":"git://github.com/cookpad/streamy.git","ssh_url":"git@github.com:cookpad/streamy.git","clone_url":"https://github.com/cookpad/streamy.git","svn_url":"https://github.com/cookpad/streamy","homepage":null,"size":153,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":4,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/51"},"html":{"href":"https://github.com/cookpad/streamy/pull/51"},"issue":{"href":"https://api.github.com/repos/cookpad/streamy/issues/51"},"comments":{"href":"https://api.github.com/repos/cookpad/streamy/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cookpad/streamy/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/cookpad/streamy/statuses/932f16e427b93abe32862fd4b295d9c4e6e85c94"}},"author_association":"NONE"}}
{"actor":{"display_login":"lewispb"}}