{"action":"created","comment":{"url":"https://api.github.com/repos/klarna/brod/pulls/comments/46823240","id":46823240,"diff_hunk":"@@ -0,0 +1,73 @@\n+%%%\n+%%%   Copyright (c) 2015 Klarna AB\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+%%%=============================================================================\n+%%% @doc\n+%%% @copyright 2015 Klarna AB\n+%%% @end\n+%%%=============================================================================\n+-module(brod_sup).\n+-behaviour(brod_supervisor).\n+\n+-export([ start_link/1\n+        , init/1\n+        ]).\n+\n+-define(DEFAULT_PRODUCER_RESTART_DELAY_SECONDS, 10).\n+\n+%% @doc Start supervisor of permanent producers.\n+%% @see brod:start_link_producer/2 for more info about all producer args\n+%% @end\n+-spec start_link(proplists:proplist()) -> {ok, pid()}.\n+start_link(PermanentProducers) ->\n+  brod_supervisor:start_link({local, ?MODULE}, ?MODULE, PermanentProducers).\n+\n+init(PermanentProducers) ->\n+  Children = [permanent_producer(P) || P <- PermanentProducers],\n+  {ok, {{one_for_one, 0, 1}, Children}}.\n+\n+permanent_producer({ProducerId0, Args0}) ->\n+  KafkaHosts = proplists:get_values(hosts, Args0),\n+  case is_list(KafkaHosts) of\n+    true  -> ok;\n+    false -> erlang:throw({mandatory_prop_missing, Args0})\n+  end,\n+  RestartDelay =\n+    proplists:get_value(restart_delay_seconds, Args0,\n+                        ?DEFAULT_PRODUCER_RESTART_DELAY_SECONDS),\n+  %% no need of 'hosts' and 'restart_delay_seconds' in producer options\n+  Args1 = proplists:delete(hosts, Args0),\n+  Args  = proplists:delete(restart_delay_seconds, Args1),\n+\n+  %% In case producer_id is not given in args body, use the tag.\n+  {ProducerId, Opts} =\n+    case proplists:get_value(producer_id, Args) of\n+      undefined ->\n+        {ProducerId0, [{producer_id, ProducerId0} | Args]};\n+      ID when is_atom(ID) ->\n+        {ID, Args}\n+    end,\n+  { _Id       = ProducerId\n+  , _Start    = {brod, start_link_producer, [KafkaHosts, Opts]}\n+  , _Restart  = {permanent, RestartDelay}","path":"src/brod_sup.erl","position":65,"original_position":65,"commit_id":"756139dea381db3df6a216454cc66492222bd8ca","original_commit_id":"756139dea381db3df6a216454cc66492222bd8ca","user":{"login":"dszoboszlay","id":1025306,"avatar_url":"https://avatars.githubusercontent.com/u/1025306?v=3","gravatar_id":"","url":"https://api.github.com/users/dszoboszlay","html_url":"https://github.com/dszoboszlay","followers_url":"https://api.github.com/users/dszoboszlay/followers","following_url":"https://api.github.com/users/dszoboszlay/following{/other_user}","gists_url":"https://api.github.com/users/dszoboszlay/gists{/gist_id}","starred_url":"https://api.github.com/users/dszoboszlay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dszoboszlay/subscriptions","organizations_url":"https://api.github.com/users/dszoboszlay/orgs","repos_url":"https://api.github.com/users/dszoboszlay/repos","events_url":"https://api.github.com/users/dszoboszlay/events{/privacy}","received_events_url":"https://api.github.com/users/dszoboszlay/received_events","type":"User","site_admin":false},"body":"What's the point of the restart delay (and therefore using the `brod_supervisor` instead of the standard `supervisor`) if the restart strategy is `{one_for_one, 0, 1}`, e.g. no restarts are allowed at all?","created_at":"2015-12-07T14:04:04Z","updated_at":"2015-12-07T14:04:04Z","html_url":"https://github.com/klarna/brod/pull/8#discussion_r46823240","pull_request_url":"https://api.github.com/repos/klarna/brod/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/klarna/brod/pulls/comments/46823240"},"html":{"href":"https://github.com/klarna/brod/pull/8#discussion_r46823240"},"pull_request":{"href":"https://api.github.com/repos/klarna/brod/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/klarna/brod/pulls/8","id":52526538,"html_url":"https://github.com/klarna/brod/pull/8","diff_url":"https://github.com/klarna/brod/pull/8.diff","patch_url":"https://github.com/klarna/brod/pull/8.patch","issue_url":"https://api.github.com/repos/klarna/brod/issues/8","number":8,"state":"open","locked":false,"title":"refactor producer","user":{"login":"id","id":138221,"avatar_url":"https://avatars.githubusercontent.com/u/138221?v=3","gravatar_id":"","url":"https://api.github.com/users/id","html_url":"https://github.com/id","followers_url":"https://api.github.com/users/id/followers","following_url":"https://api.github.com/users/id/following{/other_user}","gists_url":"https://api.github.com/users/id/gists{/gist_id}","starred_url":"https://api.github.com/users/id/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/id/subscriptions","organizations_url":"https://api.github.com/users/id/orgs","repos_url":"https://api.github.com/users/id/repos","events_url":"https://api.github.com/users/id/events{/privacy}","received_events_url":"https://api.github.com/users/id/received_events","type":"User","site_admin":false},"body":"Work in progress.\r\n\r\nTODO:\r\n- refactor consumer\r\n- fix tests","created_at":"2015-12-03T12:13:39Z","updated_at":"2015-12-07T14:04:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2886efa81c6c0836ab58ee9e1432411eb76d5383","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/klarna/brod/pulls/8/commits","review_comments_url":"https://api.github.com/repos/klarna/brod/pulls/8/comments","review_comment_url":"https://api.github.com/repos/klarna/brod/pulls/comments{/number}","comments_url":"https://api.github.com/repos/klarna/brod/issues/8/comments","statuses_url":"https://api.github.com/repos/klarna/brod/statuses/756139dea381db3df6a216454cc66492222bd8ca","head":{"label":"klarna:better-error-handling","ref":"better-error-handling","sha":"756139dea381db3df6a216454cc66492222bd8ca","user":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"repo":{"id":31531585,"name":"brod","full_name":"klarna/brod","owner":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/klarna/brod","description":"Client for Apache Kafka in Erlang","fork":false,"url":"https://api.github.com/repos/klarna/brod","forks_url":"https://api.github.com/repos/klarna/brod/forks","keys_url":"https://api.github.com/repos/klarna/brod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klarna/brod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klarna/brod/teams","hooks_url":"https://api.github.com/repos/klarna/brod/hooks","issue_events_url":"https://api.github.com/repos/klarna/brod/issues/events{/number}","events_url":"https://api.github.com/repos/klarna/brod/events","assignees_url":"https://api.github.com/repos/klarna/brod/assignees{/user}","branches_url":"https://api.github.com/repos/klarna/brod/branches{/branch}","tags_url":"https://api.github.com/repos/klarna/brod/tags","blobs_url":"https://api.github.com/repos/klarna/brod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klarna/brod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klarna/brod/git/refs{/sha}","trees_url":"https://api.github.com/repos/klarna/brod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klarna/brod/statuses/{sha}","languages_url":"https://api.github.com/repos/klarna/brod/languages","stargazers_url":"https://api.github.com/repos/klarna/brod/stargazers","contributors_url":"https://api.github.com/repos/klarna/brod/contributors","subscribers_url":"https://api.github.com/repos/klarna/brod/subscribers","subscription_url":"https://api.github.com/repos/klarna/brod/subscription","commits_url":"https://api.github.com/repos/klarna/brod/commits{/sha}","git_commits_url":"https://api.github.com/repos/klarna/brod/git/commits{/sha}","comments_url":"https://api.github.com/repos/klarna/brod/comments{/number}","issue_comment_url":"https://api.github.com/repos/klarna/brod/issues/comments{/number}","contents_url":"https://api.github.com/repos/klarna/brod/contents/{+path}","compare_url":"https://api.github.com/repos/klarna/brod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klarna/brod/merges","archive_url":"https://api.github.com/repos/klarna/brod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klarna/brod/downloads","issues_url":"https://api.github.com/repos/klarna/brod/issues{/number}","pulls_url":"https://api.github.com/repos/klarna/brod/pulls{/number}","milestones_url":"https://api.github.com/repos/klarna/brod/milestones{/number}","notifications_url":"https://api.github.com/repos/klarna/brod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klarna/brod/labels{/name}","releases_url":"https://api.github.com/repos/klarna/brod/releases{/id}","created_at":"2015-03-02T09:02:18Z","updated_at":"2015-11-25T12:15:01Z","pushed_at":"2015-12-07T12:18:05Z","git_url":"git://github.com/klarna/brod.git","ssh_url":"git@github.com:klarna/brod.git","clone_url":"https://github.com/klarna/brod.git","svn_url":"https://github.com/klarna/brod","homepage":null,"size":699,"stargazers_count":33,"watchers_count":33,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":33,"default_branch":"master"}},"base":{"label":"klarna:master","ref":"master","sha":"98cc43767ba3b3308b3701bb4d0c56a32b249e8c","user":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"repo":{"id":31531585,"name":"brod","full_name":"klarna/brod","owner":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/klarna/brod","description":"Client for Apache Kafka in Erlang","fork":false,"url":"https://api.github.com/repos/klarna/brod","forks_url":"https://api.github.com/repos/klarna/brod/forks","keys_url":"https://api.github.com/repos/klarna/brod/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klarna/brod/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klarna/brod/teams","hooks_url":"https://api.github.com/repos/klarna/brod/hooks","issue_events_url":"https://api.github.com/repos/klarna/brod/issues/events{/number}","events_url":"https://api.github.com/repos/klarna/brod/events","assignees_url":"https://api.github.com/repos/klarna/brod/assignees{/user}","branches_url":"https://api.github.com/repos/klarna/brod/branches{/branch}","tags_url":"https://api.github.com/repos/klarna/brod/tags","blobs_url":"https://api.github.com/repos/klarna/brod/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klarna/brod/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klarna/brod/git/refs{/sha}","trees_url":"https://api.github.com/repos/klarna/brod/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klarna/brod/statuses/{sha}","languages_url":"https://api.github.com/repos/klarna/brod/languages","stargazers_url":"https://api.github.com/repos/klarna/brod/stargazers","contributors_url":"https://api.github.com/repos/klarna/brod/contributors","subscribers_url":"https://api.github.com/repos/klarna/brod/subscribers","subscription_url":"https://api.github.com/repos/klarna/brod/subscription","commits_url":"https://api.github.com/repos/klarna/brod/commits{/sha}","git_commits_url":"https://api.github.com/repos/klarna/brod/git/commits{/sha}","comments_url":"https://api.github.com/repos/klarna/brod/comments{/number}","issue_comment_url":"https://api.github.com/repos/klarna/brod/issues/comments{/number}","contents_url":"https://api.github.com/repos/klarna/brod/contents/{+path}","compare_url":"https://api.github.com/repos/klarna/brod/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klarna/brod/merges","archive_url":"https://api.github.com/repos/klarna/brod/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klarna/brod/downloads","issues_url":"https://api.github.com/repos/klarna/brod/issues{/number}","pulls_url":"https://api.github.com/repos/klarna/brod/pulls{/number}","milestones_url":"https://api.github.com/repos/klarna/brod/milestones{/number}","notifications_url":"https://api.github.com/repos/klarna/brod/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klarna/brod/labels{/name}","releases_url":"https://api.github.com/repos/klarna/brod/releases{/id}","created_at":"2015-03-02T09:02:18Z","updated_at":"2015-11-25T12:15:01Z","pushed_at":"2015-12-07T12:18:05Z","git_url":"git://github.com/klarna/brod.git","ssh_url":"git@github.com:klarna/brod.git","clone_url":"https://github.com/klarna/brod.git","svn_url":"https://github.com/klarna/brod","homepage":null,"size":699,"stargazers_count":33,"watchers_count":33,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/klarna/brod/pulls/8"},"html":{"href":"https://github.com/klarna/brod/pull/8"},"issue":{"href":"https://api.github.com/repos/klarna/brod/issues/8"},"comments":{"href":"https://api.github.com/repos/klarna/brod/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/klarna/brod/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/klarna/brod/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/klarna/brod/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/klarna/brod/statuses/756139dea381db3df6a216454cc66492222bd8ca"}}}}