{"action":"created","comment":{"url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/comments/41377384","id":41377384,"diff_hunk":"@@ -120,8 +117,32 @@ class locator_t:\n     // Snapshots of the local service states. Synchronized with outgoing remote streams.\n     std::map<std::string, results::resolve> m_snapshots;\n \n-    // Outgoing router streams indexed by some arbitrary router-provided uuid.\n-    synchronized<router_map_t> m_routers;\n+    struct routing_t {\n+        enum class policy_t {\n+            // Reuse the routing stream if it exists.\n+            reuse,\n+            // Replace existing routing stream even if the keys are same.\n+            replace\n+        };\n+\n+        const logging::log_t& log;\n+\n+        // Used to resolve service names against routing groups, based on weights and other metrics.\n+        synchronized<rg_map_t> groups;\n+\n+        // Outgoing router streams indexed by some arbitrary router-provided uuid.\n+        synchronized<router_map_t> routers;\n+\n+        routing_t(const logging::log_t& log):\n+            log(log)\n+        {}\n+\n+        results::routing\n+        dump() const;\n+\n+        streamed<results::routing>\n+        notify(const std::string& ruid, const results::routing& results, policy_t policy = policy_t::reuse);","path":"include/cocaine/detail/service/locator.hpp","position":40,"original_position":40,"commit_id":"bd22981f889013fb617d8d450bd9978376e77e41","original_commit_id":"bd22981f889013fb617d8d450bd9978376e77e41","user":{"login":"antmat","id":691770,"avatar_url":"https://avatars.githubusercontent.com/u/691770?v=3","gravatar_id":"","url":"https://api.github.com/users/antmat","html_url":"https://github.com/antmat","followers_url":"https://api.github.com/users/antmat/followers","following_url":"https://api.github.com/users/antmat/following{/other_user}","gists_url":"https://api.github.com/users/antmat/gists{/gist_id}","starred_url":"https://api.github.com/users/antmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antmat/subscriptions","organizations_url":"https://api.github.com/users/antmat/orgs","repos_url":"https://api.github.com/users/antmat/repos","events_url":"https://api.github.com/users/antmat/events{/privacy}","received_events_url":"https://api.github.com/users/antmat/received_events","type":"User","site_admin":false},"body":"I would also drop default value here.","created_at":"2015-10-07T11:07:00Z","updated_at":"2015-10-07T11:07:00Z","html_url":"https://github.com/cocaine/cocaine-core/pull/247#discussion_r41377384","pull_request_url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247","_links":{"self":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/comments/41377384"},"html":{"href":"https://github.com/cocaine/cocaine-core/pull/247#discussion_r41377384"},"pull_request":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247"}}},"pull_request":{"url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247","id":47008775,"html_url":"https://github.com/cocaine/cocaine-core/pull/247","diff_url":"https://github.com/cocaine/cocaine-core/pull/247.diff","patch_url":"https://github.com/cocaine/cocaine-core/pull/247.patch","issue_url":"https://api.github.com/repos/cocaine/cocaine-core/issues/247","number":247,"state":"open","locked":false,"title":"perf(locator): prepare/commit for groups refresh","user":{"login":"3Hren","id":969900,"avatar_url":"https://avatars.githubusercontent.com/u/969900?v=3","gravatar_id":"","url":"https://api.github.com/users/3Hren","html_url":"https://github.com/3Hren","followers_url":"https://api.github.com/users/3Hren/followers","following_url":"https://api.github.com/users/3Hren/following{/other_user}","gists_url":"https://api.github.com/users/3Hren/gists{/gist_id}","starred_url":"https://api.github.com/users/3Hren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3Hren/subscriptions","organizations_url":"https://api.github.com/users/3Hren/orgs","repos_url":"https://api.github.com/users/3Hren/repos","events_url":"https://api.github.com/users/3Hren/events{/privacy}","received_events_url":"https://api.github.com/users/3Hren/received_events","type":"User","site_admin":false},"body":"This commit decomposes the prepare and broadcast logic for\r\nmassive routing groups refresh.\r\n\r\nWhen we iterate over outgoing streams to notify each there\r\nis no need to rebuild routing map every iteration.\r\n\r\nAlso the bool `replace` flag is replaced with named enum.\r\n\r\nPresence of boolean flags in method signatures is anti-pattern, because\r\nwhen you invoke such method you should always switch to its\r\ndeclaration to match what that `true` or `false` value actually\r\nmeans.","created_at":"2015-10-07T10:11:16Z","updated_at":"2015-10-07T11:07:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"921b4782b5605dfe14686c4ebe3586945f2dd2e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247/commits","review_comments_url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247/comments","review_comment_url":"https://api.github.com/repos/cocaine/cocaine-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cocaine/cocaine-core/issues/247/comments","statuses_url":"https://api.github.com/repos/cocaine/cocaine-core/statuses/bd22981f889013fb617d8d450bd9978376e77e41","head":{"label":"3Hren:pr/locator-prepare-commit","ref":"pr/locator-prepare-commit","sha":"bd22981f889013fb617d8d450bd9978376e77e41","user":{"login":"3Hren","id":969900,"avatar_url":"https://avatars.githubusercontent.com/u/969900?v=3","gravatar_id":"","url":"https://api.github.com/users/3Hren","html_url":"https://github.com/3Hren","followers_url":"https://api.github.com/users/3Hren/followers","following_url":"https://api.github.com/users/3Hren/following{/other_user}","gists_url":"https://api.github.com/users/3Hren/gists{/gist_id}","starred_url":"https://api.github.com/users/3Hren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3Hren/subscriptions","organizations_url":"https://api.github.com/users/3Hren/orgs","repos_url":"https://api.github.com/users/3Hren/repos","events_url":"https://api.github.com/users/3Hren/events{/privacy}","received_events_url":"https://api.github.com/users/3Hren/received_events","type":"User","site_admin":false},"repo":{"id":11948568,"name":"cocaine-core","full_name":"3Hren/cocaine-core","owner":{"login":"3Hren","id":969900,"avatar_url":"https://avatars.githubusercontent.com/u/969900?v=3","gravatar_id":"","url":"https://api.github.com/users/3Hren","html_url":"https://github.com/3Hren","followers_url":"https://api.github.com/users/3Hren/followers","following_url":"https://api.github.com/users/3Hren/following{/other_user}","gists_url":"https://api.github.com/users/3Hren/gists{/gist_id}","starred_url":"https://api.github.com/users/3Hren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3Hren/subscriptions","organizations_url":"https://api.github.com/users/3Hren/orgs","repos_url":"https://api.github.com/users/3Hren/repos","events_url":"https://api.github.com/users/3Hren/events{/privacy}","received_events_url":"https://api.github.com/users/3Hren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/3Hren/cocaine-core","description":"Cocaine Application Engine","fork":true,"url":"https://api.github.com/repos/3Hren/cocaine-core","forks_url":"https://api.github.com/repos/3Hren/cocaine-core/forks","keys_url":"https://api.github.com/repos/3Hren/cocaine-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3Hren/cocaine-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3Hren/cocaine-core/teams","hooks_url":"https://api.github.com/repos/3Hren/cocaine-core/hooks","issue_events_url":"https://api.github.com/repos/3Hren/cocaine-core/issues/events{/number}","events_url":"https://api.github.com/repos/3Hren/cocaine-core/events","assignees_url":"https://api.github.com/repos/3Hren/cocaine-core/assignees{/user}","branches_url":"https://api.github.com/repos/3Hren/cocaine-core/branches{/branch}","tags_url":"https://api.github.com/repos/3Hren/cocaine-core/tags","blobs_url":"https://api.github.com/repos/3Hren/cocaine-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3Hren/cocaine-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3Hren/cocaine-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/3Hren/cocaine-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3Hren/cocaine-core/statuses/{sha}","languages_url":"https://api.github.com/repos/3Hren/cocaine-core/languages","stargazers_url":"https://api.github.com/repos/3Hren/cocaine-core/stargazers","contributors_url":"https://api.github.com/repos/3Hren/cocaine-core/contributors","subscribers_url":"https://api.github.com/repos/3Hren/cocaine-core/subscribers","subscription_url":"https://api.github.com/repos/3Hren/cocaine-core/subscription","commits_url":"https://api.github.com/repos/3Hren/cocaine-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/3Hren/cocaine-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/3Hren/cocaine-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/3Hren/cocaine-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/3Hren/cocaine-core/contents/{+path}","compare_url":"https://api.github.com/repos/3Hren/cocaine-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3Hren/cocaine-core/merges","archive_url":"https://api.github.com/repos/3Hren/cocaine-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3Hren/cocaine-core/downloads","issues_url":"https://api.github.com/repos/3Hren/cocaine-core/issues{/number}","pulls_url":"https://api.github.com/repos/3Hren/cocaine-core/pulls{/number}","milestones_url":"https://api.github.com/repos/3Hren/cocaine-core/milestones{/number}","notifications_url":"https://api.github.com/repos/3Hren/cocaine-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3Hren/cocaine-core/labels{/name}","releases_url":"https://api.github.com/repos/3Hren/cocaine-core/releases{/id}","created_at":"2013-08-07T11:36:51Z","updated_at":"2015-04-23T09:46:28Z","pushed_at":"2015-10-07T10:33:16Z","git_url":"git://github.com/3Hren/cocaine-core.git","ssh_url":"git@github.com:3Hren/cocaine-core.git","clone_url":"https://github.com/3Hren/cocaine-core.git","svn_url":"https://github.com/3Hren/cocaine-core","homepage":"","size":14695,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"nightly"}},"base":{"label":"cocaine:v0.12","ref":"v0.12","sha":"7439ea1b080ee3b6ebdde99dbbd4fadae9c8f105","user":{"login":"cocaine","id":1553730,"avatar_url":"https://avatars.githubusercontent.com/u/1553730?v=3","gravatar_id":"","url":"https://api.github.com/users/cocaine","html_url":"https://github.com/cocaine","followers_url":"https://api.github.com/users/cocaine/followers","following_url":"https://api.github.com/users/cocaine/following{/other_user}","gists_url":"https://api.github.com/users/cocaine/gists{/gist_id}","starred_url":"https://api.github.com/users/cocaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cocaine/subscriptions","organizations_url":"https://api.github.com/users/cocaine/orgs","repos_url":"https://api.github.com/users/cocaine/repos","events_url":"https://api.github.com/users/cocaine/events{/privacy}","received_events_url":"https://api.github.com/users/cocaine/received_events","type":"Organization","site_admin":false},"repo":{"id":1516094,"name":"cocaine-core","full_name":"cocaine/cocaine-core","owner":{"login":"cocaine","id":1553730,"avatar_url":"https://avatars.githubusercontent.com/u/1553730?v=3","gravatar_id":"","url":"https://api.github.com/users/cocaine","html_url":"https://github.com/cocaine","followers_url":"https://api.github.com/users/cocaine/followers","following_url":"https://api.github.com/users/cocaine/following{/other_user}","gists_url":"https://api.github.com/users/cocaine/gists{/gist_id}","starred_url":"https://api.github.com/users/cocaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cocaine/subscriptions","organizations_url":"https://api.github.com/users/cocaine/orgs","repos_url":"https://api.github.com/users/cocaine/repos","events_url":"https://api.github.com/users/cocaine/events{/privacy}","received_events_url":"https://api.github.com/users/cocaine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cocaine/cocaine-core","description":"An open platform to build your own PaaS clouds.","fork":false,"url":"https://api.github.com/repos/cocaine/cocaine-core","forks_url":"https://api.github.com/repos/cocaine/cocaine-core/forks","keys_url":"https://api.github.com/repos/cocaine/cocaine-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cocaine/cocaine-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cocaine/cocaine-core/teams","hooks_url":"https://api.github.com/repos/cocaine/cocaine-core/hooks","issue_events_url":"https://api.github.com/repos/cocaine/cocaine-core/issues/events{/number}","events_url":"https://api.github.com/repos/cocaine/cocaine-core/events","assignees_url":"https://api.github.com/repos/cocaine/cocaine-core/assignees{/user}","branches_url":"https://api.github.com/repos/cocaine/cocaine-core/branches{/branch}","tags_url":"https://api.github.com/repos/cocaine/cocaine-core/tags","blobs_url":"https://api.github.com/repos/cocaine/cocaine-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cocaine/cocaine-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cocaine/cocaine-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/cocaine/cocaine-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cocaine/cocaine-core/statuses/{sha}","languages_url":"https://api.github.com/repos/cocaine/cocaine-core/languages","stargazers_url":"https://api.github.com/repos/cocaine/cocaine-core/stargazers","contributors_url":"https://api.github.com/repos/cocaine/cocaine-core/contributors","subscribers_url":"https://api.github.com/repos/cocaine/cocaine-core/subscribers","subscription_url":"https://api.github.com/repos/cocaine/cocaine-core/subscription","commits_url":"https://api.github.com/repos/cocaine/cocaine-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/cocaine/cocaine-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/cocaine/cocaine-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/cocaine/cocaine-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/cocaine/cocaine-core/contents/{+path}","compare_url":"https://api.github.com/repos/cocaine/cocaine-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cocaine/cocaine-core/merges","archive_url":"https://api.github.com/repos/cocaine/cocaine-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cocaine/cocaine-core/downloads","issues_url":"https://api.github.com/repos/cocaine/cocaine-core/issues{/number}","pulls_url":"https://api.github.com/repos/cocaine/cocaine-core/pulls{/number}","milestones_url":"https://api.github.com/repos/cocaine/cocaine-core/milestones{/number}","notifications_url":"https://api.github.com/repos/cocaine/cocaine-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cocaine/cocaine-core/labels{/name}","releases_url":"https://api.github.com/repos/cocaine/cocaine-core/releases{/id}","created_at":"2011-03-23T12:31:26Z","updated_at":"2015-10-05T19:14:33Z","pushed_at":"2015-10-07T10:11:16Z","git_url":"git://github.com/cocaine/cocaine-core.git","ssh_url":"git@github.com:cocaine/cocaine-core.git","clone_url":"https://github.com/cocaine/cocaine-core.git","svn_url":"https://github.com/cocaine/cocaine-core","homepage":"","size":19632,"stargazers_count":838,"watchers_count":838,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":7,"forks":76,"open_issues":7,"watchers":838,"default_branch":"v0.12"}},"_links":{"self":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247"},"html":{"href":"https://github.com/cocaine/cocaine-core/pull/247"},"issue":{"href":"https://api.github.com/repos/cocaine/cocaine-core/issues/247"},"comments":{"href":"https://api.github.com/repos/cocaine/cocaine-core/issues/247/comments"},"review_comments":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247/comments"},"review_comment":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cocaine/cocaine-core/pulls/247/commits"},"statuses":{"href":"https://api.github.com/repos/cocaine/cocaine-core/statuses/bd22981f889013fb617d8d450bd9978376e77e41"}}}}