{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/comments/57735434","id":57735434,"diff_hunk":"@@ -290,6 +290,12 @@ def deliver_messages_with_retries(notification)\n \n         if buffer_size.zero?\n           break\n+        elsif @required_acks.zero?\n+          # No response is returned by the brokers, so we can't know which messages\n+          # have been successfully written. Our only option is to assume that they all\n+          # have.\n+          @buffer.clear\n+          break\n         elsif attempt <= @max_retries\n           @logger.warn \"Failed to send all messages; attempting retry #{attempt} of #{@max_retries} after #{@retry_backoff}s\"","path":"lib/kafka/producer.rb","position":11,"original_position":11,"commit_id":"7ebe5812d690a7aedb388ca25c40f2e46a47895d","original_commit_id":"7ebe5812d690a7aedb388ca25c40f2e46a47895d","user":{"login":"mensfeld","id":392754,"avatar_url":"https://avatars.githubusercontent.com/u/392754?v=3","gravatar_id":"","url":"https://api.github.com/users/mensfeld","html_url":"https://github.com/mensfeld","followers_url":"https://api.github.com/users/mensfeld/followers","following_url":"https://api.github.com/users/mensfeld/following{/other_user}","gists_url":"https://api.github.com/users/mensfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/mensfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mensfeld/subscriptions","organizations_url":"https://api.github.com/users/mensfeld/orgs","repos_url":"https://api.github.com/users/mensfeld/repos","events_url":"https://api.github.com/users/mensfeld/events{/privacy}","received_events_url":"https://api.github.com/users/mensfeld/received_events","type":"User","site_admin":false},"body":"wouldn't it be more readable if we would just break if... break if...?","created_at":"2016-03-29T14:45:20Z","updated_at":"2016-03-29T14:45:20Z","html_url":"https://github.com/zendesk/ruby-kafka/pull/147#discussion_r57735434","pull_request_url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147","_links":{"self":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/comments/57735434"},"html":{"href":"https://github.com/zendesk/ruby-kafka/pull/147#discussion_r57735434"},"pull_request":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147","id":63946068,"html_url":"https://github.com/zendesk/ruby-kafka/pull/147","diff_url":"https://github.com/zendesk/ruby-kafka/pull/147.diff","patch_url":"https://github.com/zendesk/ruby-kafka/pull/147.patch","issue_url":"https://api.github.com/repos/zendesk/ruby-kafka/issues/147","number":147,"state":"open","locked":false,"title":"Producer should not retry when required_acks is 0","user":{"login":"repeatedly","id":16928,"avatar_url":"https://avatars.githubusercontent.com/u/16928?v=3","gravatar_id":"","url":"https://api.github.com/users/repeatedly","html_url":"https://github.com/repeatedly","followers_url":"https://api.github.com/users/repeatedly/followers","following_url":"https://api.github.com/users/repeatedly/following{/other_user}","gists_url":"https://api.github.com/users/repeatedly/gists{/gist_id}","starred_url":"https://api.github.com/users/repeatedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repeatedly/subscriptions","organizations_url":"https://api.github.com/users/repeatedly/orgs","repos_url":"https://api.github.com/users/repeatedly/repos","events_url":"https://api.github.com/users/repeatedly/events{/privacy}","received_events_url":"https://api.github.com/users/repeatedly/received_events","type":"User","site_admin":false},"body":"required_acks 0 means the producer never waits acks from the brokers.\r\nPrevious code causes duplicated messages because buffer isn't updated\r\nby producer opertaions with required_acks 0","created_at":"2016-03-23T20:18:26Z","updated_at":"2016-03-29T14:45:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed6425a4d6d384dad96fe4b32a3da4da42f393f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147/commits","review_comments_url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147/comments","review_comment_url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/ruby-kafka/issues/147/comments","statuses_url":"https://api.github.com/repos/zendesk/ruby-kafka/statuses/7ebe5812d690a7aedb388ca25c40f2e46a47895d","head":{"label":"repeatedly:fix-retry-action-with-required_acks-0","ref":"fix-retry-action-with-required_acks-0","sha":"7ebe5812d690a7aedb388ca25c40f2e46a47895d","user":{"login":"repeatedly","id":16928,"avatar_url":"https://avatars.githubusercontent.com/u/16928?v=3","gravatar_id":"","url":"https://api.github.com/users/repeatedly","html_url":"https://github.com/repeatedly","followers_url":"https://api.github.com/users/repeatedly/followers","following_url":"https://api.github.com/users/repeatedly/following{/other_user}","gists_url":"https://api.github.com/users/repeatedly/gists{/gist_id}","starred_url":"https://api.github.com/users/repeatedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repeatedly/subscriptions","organizations_url":"https://api.github.com/users/repeatedly/orgs","repos_url":"https://api.github.com/users/repeatedly/repos","events_url":"https://api.github.com/users/repeatedly/events{/privacy}","received_events_url":"https://api.github.com/users/repeatedly/received_events","type":"User","site_admin":false},"repo":{"id":54566696,"name":"ruby-kafka","full_name":"repeatedly/ruby-kafka","owner":{"login":"repeatedly","id":16928,"avatar_url":"https://avatars.githubusercontent.com/u/16928?v=3","gravatar_id":"","url":"https://api.github.com/users/repeatedly","html_url":"https://github.com/repeatedly","followers_url":"https://api.github.com/users/repeatedly/followers","following_url":"https://api.github.com/users/repeatedly/following{/other_user}","gists_url":"https://api.github.com/users/repeatedly/gists{/gist_id}","starred_url":"https://api.github.com/users/repeatedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repeatedly/subscriptions","organizations_url":"https://api.github.com/users/repeatedly/orgs","repos_url":"https://api.github.com/users/repeatedly/repos","events_url":"https://api.github.com/users/repeatedly/events{/privacy}","received_events_url":"https://api.github.com/users/repeatedly/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/repeatedly/ruby-kafka","description":"A Ruby client library for Apache Kafka 0.9","fork":true,"url":"https://api.github.com/repos/repeatedly/ruby-kafka","forks_url":"https://api.github.com/repos/repeatedly/ruby-kafka/forks","keys_url":"https://api.github.com/repos/repeatedly/ruby-kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/repeatedly/ruby-kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/repeatedly/ruby-kafka/teams","hooks_url":"https://api.github.com/repos/repeatedly/ruby-kafka/hooks","issue_events_url":"https://api.github.com/repos/repeatedly/ruby-kafka/issues/events{/number}","events_url":"https://api.github.com/repos/repeatedly/ruby-kafka/events","assignees_url":"https://api.github.com/repos/repeatedly/ruby-kafka/assignees{/user}","branches_url":"https://api.github.com/repos/repeatedly/ruby-kafka/branches{/branch}","tags_url":"https://api.github.com/repos/repeatedly/ruby-kafka/tags","blobs_url":"https://api.github.com/repos/repeatedly/ruby-kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/repeatedly/ruby-kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/repeatedly/ruby-kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/repeatedly/ruby-kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/repeatedly/ruby-kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/repeatedly/ruby-kafka/languages","stargazers_url":"https://api.github.com/repos/repeatedly/ruby-kafka/stargazers","contributors_url":"https://api.github.com/repos/repeatedly/ruby-kafka/contributors","subscribers_url":"https://api.github.com/repos/repeatedly/ruby-kafka/subscribers","subscription_url":"https://api.github.com/repos/repeatedly/ruby-kafka/subscription","commits_url":"https://api.github.com/repos/repeatedly/ruby-kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/repeatedly/ruby-kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/repeatedly/ruby-kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/repeatedly/ruby-kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/repeatedly/ruby-kafka/contents/{+path}","compare_url":"https://api.github.com/repos/repeatedly/ruby-kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/repeatedly/ruby-kafka/merges","archive_url":"https://api.github.com/repos/repeatedly/ruby-kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/repeatedly/ruby-kafka/downloads","issues_url":"https://api.github.com/repos/repeatedly/ruby-kafka/issues{/number}","pulls_url":"https://api.github.com/repos/repeatedly/ruby-kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/repeatedly/ruby-kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/repeatedly/ruby-kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/repeatedly/ruby-kafka/labels{/name}","releases_url":"https://api.github.com/repos/repeatedly/ruby-kafka/releases{/id}","deployments_url":"https://api.github.com/repos/repeatedly/ruby-kafka/deployments","created_at":"2016-03-23T14:32:03Z","updated_at":"2016-03-23T14:32:04Z","pushed_at":"2016-03-23T22:19:14Z","git_url":"git://github.com/repeatedly/ruby-kafka.git","ssh_url":"git@github.com:repeatedly/ruby-kafka.git","clone_url":"https://github.com/repeatedly/ruby-kafka.git","svn_url":"https://github.com/repeatedly/ruby-kafka","homepage":"http://www.rubydoc.info/gems/ruby-kafka","size":368,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"zendesk:master","ref":"master","sha":"7ffcf2c953b3560014c9312533e6a7eed8663fb4","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":49878403,"name":"ruby-kafka","full_name":"zendesk/ruby-kafka","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/ruby-kafka","description":"A Ruby client library for Apache Kafka 0.9","fork":false,"url":"https://api.github.com/repos/zendesk/ruby-kafka","forks_url":"https://api.github.com/repos/zendesk/ruby-kafka/forks","keys_url":"https://api.github.com/repos/zendesk/ruby-kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/ruby-kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/ruby-kafka/teams","hooks_url":"https://api.github.com/repos/zendesk/ruby-kafka/hooks","issue_events_url":"https://api.github.com/repos/zendesk/ruby-kafka/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/ruby-kafka/events","assignees_url":"https://api.github.com/repos/zendesk/ruby-kafka/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/ruby-kafka/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/ruby-kafka/tags","blobs_url":"https://api.github.com/repos/zendesk/ruby-kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/ruby-kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/ruby-kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/ruby-kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/ruby-kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/ruby-kafka/languages","stargazers_url":"https://api.github.com/repos/zendesk/ruby-kafka/stargazers","contributors_url":"https://api.github.com/repos/zendesk/ruby-kafka/contributors","subscribers_url":"https://api.github.com/repos/zendesk/ruby-kafka/subscribers","subscription_url":"https://api.github.com/repos/zendesk/ruby-kafka/subscription","commits_url":"https://api.github.com/repos/zendesk/ruby-kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/ruby-kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/ruby-kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/ruby-kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/ruby-kafka/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/ruby-kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/ruby-kafka/merges","archive_url":"https://api.github.com/repos/zendesk/ruby-kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/ruby-kafka/downloads","issues_url":"https://api.github.com/repos/zendesk/ruby-kafka/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/ruby-kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/ruby-kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/ruby-kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/ruby-kafka/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/ruby-kafka/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/ruby-kafka/deployments","created_at":"2016-01-18T13:24:55Z","updated_at":"2016-03-28T12:46:35Z","pushed_at":"2016-03-29T08:45:57Z","git_url":"git://github.com/zendesk/ruby-kafka.git","ssh_url":"git@github.com:zendesk/ruby-kafka.git","clone_url":"https://github.com/zendesk/ruby-kafka.git","svn_url":"https://github.com/zendesk/ruby-kafka","homepage":"http://www.rubydoc.info/gems/ruby-kafka","size":396,"stargazers_count":155,"watchers_count":155,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":20,"forks":13,"open_issues":20,"watchers":155,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147"},"html":{"href":"https://github.com/zendesk/ruby-kafka/pull/147"},"issue":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/issues/147"},"comments":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/issues/147/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/pulls/147/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/ruby-kafka/statuses/7ebe5812d690a7aedb388ca25c40f2e46a47895d"}}}}