{"action":"created","comment":{"url":"https://api.github.com/repos/istio/pilot/pulls/comments/136214085","pull_request_review_id":59716497,"id":136214085,"diff_hunk":"@@ -0,0 +1,132 @@\n+// Copyright 2017 Istio Authors\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+package aggregate\n+\n+import (\n+\t\"github.com/golang/glog\"\n+\n+\t\"istio.io/pilot/model\"\n+\t\"istio.io/pilot/platform\"\n+)\n+\n+// Registry specifies the collection of service registry related interfaces\n+type Registry interface {\n+\tmodel.Controller\n+\tmodel.ServiceDiscovery\n+\tmodel.ServiceAccounts\n+}\n+\n+// Controller aggregates data across different registries and monitors for changes\n+type Controller struct {\n+\tregistries map[platform.ServiceRegistry]Registry\n+}\n+\n+// NewController creates a new Aggregate controller\n+func NewController(registries map[platform.ServiceRegistry]Registry) *Controller {\n+\treturn &Controller{\n+\t\tregistries: registries,\n+\t}\n+}\n+\n+// Services list declarations of all services in the system\n+func (c *Controller) Services() []*model.Service {\n+\tservices := make([]*model.Service, 0)\n+\tfor _, r := range c.registries {\n+\t\tservices = append(services, r.Services()...)\n+\t}\n+\treturn services\n+}\n+\n+// GetService retrieves a service by host name if it exists\n+func (c *Controller) GetService(hostname string) (*model.Service, bool) {\n+\tfor _, r := range c.registries {\n+\t\tif service, exists := r.GetService(hostname); exists {\n+\t\t\treturn service, true\n+\t\t}\n+\t}\n+\treturn nil, false\n+}\n+\n+// ManagementPorts retries set of health check ports by instance IP.\n+// Return on the first hit.\n+func (c *Controller) ManagementPorts(addr string) model.PortList {\n+\tfor _, r := range c.registries {\n+\t\tif portList := r.ManagementPorts(addr); portList != nil {\n+\t\t\treturn portList\n+\t\t}\n+\t}\n+\treturn nil\n+}\n+\n+// Instances retrieves instances for a service and its ports that match\n+// any of the supplied tags. All instances match an empty tag list.\n+func (c *Controller) Instances(hostname string, ports []string, tags model.TagsList) []*model.ServiceInstance {\n+\tinstances := make([]*model.ServiceInstance, 0)\n+\tfor _, r := range c.registries {\n+\t\tinstances = append(instances, r.Instances(hostname, ports, tags)...)\n+\t}\n+\treturn instances\n+}\n+\n+// HostInstances lists service instances for a given set of IPv4 addresses.\n+func (c *Controller) HostInstances(addrs map[string]bool) []*model.ServiceInstance {\n+\tinstances := make([]*model.ServiceInstance, 0)\n+\tfor _, r := range c.registries {\n+\t\tinstances = append(instances, r.HostInstances(addrs)...)\n+\t}\n+\treturn instances\n+}\n+\n+// Run all controllers until a signal is received\n+func (c *Controller) Run(stop <-chan struct{}) {\n+\tfor _, r := range c.registries {\n+\t\tgo r.Run(stop)\n+\t}\n+\n+\t<-stop\n+\tglog.V(2).Info(\"Registry Aggregator terminated\")\n+}\n+\n+// AppendServiceHandler implements a service catalog operation\n+func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event)) error {","path":"adapter/serviceregistry/aggregate/controller.go","position":103,"original_position":103,"commit_id":"e00fd5ec05d8024654aded2bce054b3014bd6560","original_commit_id":"e00fd5ec05d8024654aded2bce054b3014bd6560","user":{"login":"kyessenov","id":9537734,"avatar_url":"https://avatars2.githubusercontent.com/u/9537734?v=4","gravatar_id":"","url":"https://api.github.com/users/kyessenov","html_url":"https://github.com/kyessenov","followers_url":"https://api.github.com/users/kyessenov/followers","following_url":"https://api.github.com/users/kyessenov/following{/other_user}","gists_url":"https://api.github.com/users/kyessenov/gists{/gist_id}","starred_url":"https://api.github.com/users/kyessenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyessenov/subscriptions","organizations_url":"https://api.github.com/users/kyessenov/orgs","repos_url":"https://api.github.com/users/kyessenov/repos","events_url":"https://api.github.com/users/kyessenov/events{/privacy}","received_events_url":"https://api.github.com/users/kyessenov/received_events","type":"User","site_admin":false},"body":"we might need a queue to serialize the events. otherwise, `f` can be called concurrently from multiple controllers. documenting this is necessary here or in model.","created_at":"2017-08-30T23:22:56Z","updated_at":"2017-08-30T23:24:59Z","html_url":"https://github.com/istio/pilot/pull/1137#discussion_r136214085","pull_request_url":"https://api.github.com/repos/istio/pilot/pulls/1137","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/istio/pilot/pulls/comments/136214085"},"html":{"href":"https://github.com/istio/pilot/pull/1137#discussion_r136214085"},"pull_request":{"href":"https://api.github.com/repos/istio/pilot/pulls/1137"}}},"pull_request":{"url":"https://api.github.com/repos/istio/pilot/pulls/1137","id":138302614,"html_url":"https://github.com/istio/pilot/pull/1137","diff_url":"https://github.com/istio/pilot/pull/1137.diff","patch_url":"https://github.com/istio/pilot/pull/1137.patch","issue_url":"https://api.github.com/repos/istio/pilot/issues/1137","number":1137,"state":"open","locked":false,"title":"Use registry aggregator","user":{"login":"rshriram","id":8202871,"avatar_url":"https://avatars1.githubusercontent.com/u/8202871?v=4","gravatar_id":"","url":"https://api.github.com/users/rshriram","html_url":"https://github.com/rshriram","followers_url":"https://api.github.com/users/rshriram/followers","following_url":"https://api.github.com/users/rshriram/following{/other_user}","gists_url":"https://api.github.com/users/rshriram/gists{/gist_id}","starred_url":"https://api.github.com/users/rshriram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rshriram/subscriptions","organizations_url":"https://api.github.com/users/rshriram/orgs","repos_url":"https://api.github.com/users/rshriram/repos","events_url":"https://api.github.com/users/rshriram/events{/privacy}","received_events_url":"https://api.github.com/users/rshriram/received_events","type":"User","site_admin":false},"body":"**What this PR does / why we need it**:\r\nCreates a registry aggregator (similar to config aggregator) and uses that as the registry interface for proxy agents \r\n**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #\r\nfixes #1128 \r\n**Special notes for your reviewer**:\r\n\r\n**Release note**:\r\n<!--  Steps to write your release note:\r\n1. Use the release-note-* labels to set the release note state (if you have access)\r\n2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`.\r\n-->\r\n```release-note\r\nRead simultaneously from multiple service registries\r\n```\r\n","created_at":"2017-08-29T22:56:51Z","updated_at":"2017-08-30T23:24:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b84e8418cc5c0ba30825f3517e604242bc34beb5","assignee":{"login":"rshriram","id":8202871,"avatar_url":"https://avatars1.githubusercontent.com/u/8202871?v=4","gravatar_id":"","url":"https://api.github.com/users/rshriram","html_url":"https://github.com/rshriram","followers_url":"https://api.github.com/users/rshriram/followers","following_url":"https://api.github.com/users/rshriram/following{/other_user}","gists_url":"https://api.github.com/users/rshriram/gists{/gist_id}","starred_url":"https://api.github.com/users/rshriram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rshriram/subscriptions","organizations_url":"https://api.github.com/users/rshriram/orgs","repos_url":"https://api.github.com/users/rshriram/repos","events_url":"https://api.github.com/users/rshriram/events{/privacy}","received_events_url":"https://api.github.com/users/rshriram/received_events","type":"User","site_admin":false},"assignees":[{"login":"rshriram","id":8202871,"avatar_url":"https://avatars1.githubusercontent.com/u/8202871?v=4","gravatar_id":"","url":"https://api.github.com/users/rshriram","html_url":"https://github.com/rshriram","followers_url":"https://api.github.com/users/rshriram/followers","following_url":"https://api.github.com/users/rshriram/following{/other_user}","gists_url":"https://api.github.com/users/rshriram/gists{/gist_id}","starred_url":"https://api.github.com/users/rshriram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rshriram/subscriptions","organizations_url":"https://api.github.com/users/rshriram/orgs","repos_url":"https://api.github.com/users/rshriram/repos","events_url":"https://api.github.com/users/rshriram/events{/privacy}","received_events_url":"https://api.github.com/users/rshriram/received_events","type":"User","site_admin":false},{"login":"kimikowang","id":25443800,"avatar_url":"https://avatars3.githubusercontent.com/u/25443800?v=4","gravatar_id":"","url":"https://api.github.com/users/kimikowang","html_url":"https://github.com/kimikowang","followers_url":"https://api.github.com/users/kimikowang/followers","following_url":"https://api.github.com/users/kimikowang/following{/other_user}","gists_url":"https://api.github.com/users/kimikowang/gists{/gist_id}","starred_url":"https://api.github.com/users/kimikowang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimikowang/subscriptions","organizations_url":"https://api.github.com/users/kimikowang/orgs","repos_url":"https://api.github.com/users/kimikowang/repos","events_url":"https://api.github.com/users/kimikowang/events{/privacy}","received_events_url":"https://api.github.com/users/kimikowang/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/istio/pilot/milestones/2","html_url":"https://github.com/istio/pilot/milestone/2","labels_url":"https://api.github.com/repos/istio/pilot/milestones/2/labels","id":2383612,"number":2,"title":"Istio 0.2","description":"","creator":{"login":"jasminejaksic","id":23645863,"avatar_url":"https://avatars3.githubusercontent.com/u/23645863?v=4","gravatar_id":"","url":"https://api.github.com/users/jasminejaksic","html_url":"https://github.com/jasminejaksic","followers_url":"https://api.github.com/users/jasminejaksic/followers","following_url":"https://api.github.com/users/jasminejaksic/following{/other_user}","gists_url":"https://api.github.com/users/jasminejaksic/gists{/gist_id}","starred_url":"https://api.github.com/users/jasminejaksic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasminejaksic/subscriptions","organizations_url":"https://api.github.com/users/jasminejaksic/orgs","repos_url":"https://api.github.com/users/jasminejaksic/repos","events_url":"https://api.github.com/users/jasminejaksic/events{/privacy}","received_events_url":"https://api.github.com/users/jasminejaksic/received_events","type":"User","site_admin":false},"open_issues":53,"closed_issues":62,"state":"open","created_at":"2017-03-13T23:16:37Z","updated_at":"2017-08-30T21:07:56Z","due_on":"2017-09-15T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/istio/pilot/pulls/1137/commits","review_comments_url":"https://api.github.com/repos/istio/pilot/pulls/1137/comments","review_comment_url":"https://api.github.com/repos/istio/pilot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/istio/pilot/issues/1137/comments","statuses_url":"https://api.github.com/repos/istio/pilot/statuses/e00fd5ec05d8024654aded2bce054b3014bd6560","head":{"label":"istio:registry_agg","ref":"registry_agg","sha":"e00fd5ec05d8024654aded2bce054b3014bd6560","user":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"repo":{"id":75686596,"name":"pilot","full_name":"istio/pilot","owner":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/istio/pilot","description":"Istio Pilot implementation","fork":false,"url":"https://api.github.com/repos/istio/pilot","forks_url":"https://api.github.com/repos/istio/pilot/forks","keys_url":"https://api.github.com/repos/istio/pilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/istio/pilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/istio/pilot/teams","hooks_url":"https://api.github.com/repos/istio/pilot/hooks","issue_events_url":"https://api.github.com/repos/istio/pilot/issues/events{/number}","events_url":"https://api.github.com/repos/istio/pilot/events","assignees_url":"https://api.github.com/repos/istio/pilot/assignees{/user}","branches_url":"https://api.github.com/repos/istio/pilot/branches{/branch}","tags_url":"https://api.github.com/repos/istio/pilot/tags","blobs_url":"https://api.github.com/repos/istio/pilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/istio/pilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/istio/pilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/istio/pilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/istio/pilot/statuses/{sha}","languages_url":"https://api.github.com/repos/istio/pilot/languages","stargazers_url":"https://api.github.com/repos/istio/pilot/stargazers","contributors_url":"https://api.github.com/repos/istio/pilot/contributors","subscribers_url":"https://api.github.com/repos/istio/pilot/subscribers","subscription_url":"https://api.github.com/repos/istio/pilot/subscription","commits_url":"https://api.github.com/repos/istio/pilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/istio/pilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/istio/pilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/istio/pilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/istio/pilot/contents/{+path}","compare_url":"https://api.github.com/repos/istio/pilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/istio/pilot/merges","archive_url":"https://api.github.com/repos/istio/pilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/istio/pilot/downloads","issues_url":"https://api.github.com/repos/istio/pilot/issues{/number}","pulls_url":"https://api.github.com/repos/istio/pilot/pulls{/number}","milestones_url":"https://api.github.com/repos/istio/pilot/milestones{/number}","notifications_url":"https://api.github.com/repos/istio/pilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/istio/pilot/labels{/name}","releases_url":"https://api.github.com/repos/istio/pilot/releases{/id}","deployments_url":"https://api.github.com/repos/istio/pilot/deployments","created_at":"2016-12-06T02:29:57Z","updated_at":"2017-08-29T18:48:28Z","pushed_at":"2017-08-30T21:59:51Z","git_url":"git://github.com/istio/pilot.git","ssh_url":"git@github.com:istio/pilot.git","clone_url":"https://github.com/istio/pilot.git","svn_url":"https://github.com/istio/pilot","homepage":"","size":73876,"stargazers_count":105,"watchers_count":105,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":69,"mirror_url":null,"open_issues_count":100,"forks":69,"open_issues":100,"watchers":105,"default_branch":"master"}},"base":{"label":"istio:master","ref":"master","sha":"de48f4f7ca5ad7d29b52e882b61d4386e4645dd9","user":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"repo":{"id":75686596,"name":"pilot","full_name":"istio/pilot","owner":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/istio/pilot","description":"Istio Pilot implementation","fork":false,"url":"https://api.github.com/repos/istio/pilot","forks_url":"https://api.github.com/repos/istio/pilot/forks","keys_url":"https://api.github.com/repos/istio/pilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/istio/pilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/istio/pilot/teams","hooks_url":"https://api.github.com/repos/istio/pilot/hooks","issue_events_url":"https://api.github.com/repos/istio/pilot/issues/events{/number}","events_url":"https://api.github.com/repos/istio/pilot/events","assignees_url":"https://api.github.com/repos/istio/pilot/assignees{/user}","branches_url":"https://api.github.com/repos/istio/pilot/branches{/branch}","tags_url":"https://api.github.com/repos/istio/pilot/tags","blobs_url":"https://api.github.com/repos/istio/pilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/istio/pilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/istio/pilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/istio/pilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/istio/pilot/statuses/{sha}","languages_url":"https://api.github.com/repos/istio/pilot/languages","stargazers_url":"https://api.github.com/repos/istio/pilot/stargazers","contributors_url":"https://api.github.com/repos/istio/pilot/contributors","subscribers_url":"https://api.github.com/repos/istio/pilot/subscribers","subscription_url":"https://api.github.com/repos/istio/pilot/subscription","commits_url":"https://api.github.com/repos/istio/pilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/istio/pilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/istio/pilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/istio/pilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/istio/pilot/contents/{+path}","compare_url":"https://api.github.com/repos/istio/pilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/istio/pilot/merges","archive_url":"https://api.github.com/repos/istio/pilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/istio/pilot/downloads","issues_url":"https://api.github.com/repos/istio/pilot/issues{/number}","pulls_url":"https://api.github.com/repos/istio/pilot/pulls{/number}","milestones_url":"https://api.github.com/repos/istio/pilot/milestones{/number}","notifications_url":"https://api.github.com/repos/istio/pilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/istio/pilot/labels{/name}","releases_url":"https://api.github.com/repos/istio/pilot/releases{/id}","deployments_url":"https://api.github.com/repos/istio/pilot/deployments","created_at":"2016-12-06T02:29:57Z","updated_at":"2017-08-29T18:48:28Z","pushed_at":"2017-08-30T21:59:51Z","git_url":"git://github.com/istio/pilot.git","ssh_url":"git@github.com:istio/pilot.git","clone_url":"https://github.com/istio/pilot.git","svn_url":"https://github.com/istio/pilot","homepage":"","size":73876,"stargazers_count":105,"watchers_count":105,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":69,"mirror_url":null,"open_issues_count":100,"forks":69,"open_issues":100,"watchers":105,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/istio/pilot/pulls/1137"},"html":{"href":"https://github.com/istio/pilot/pull/1137"},"issue":{"href":"https://api.github.com/repos/istio/pilot/issues/1137"},"comments":{"href":"https://api.github.com/repos/istio/pilot/issues/1137/comments"},"review_comments":{"href":"https://api.github.com/repos/istio/pilot/pulls/1137/comments"},"review_comment":{"href":"https://api.github.com/repos/istio/pilot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/istio/pilot/pulls/1137/commits"},"statuses":{"href":"https://api.github.com/repos/istio/pilot/statuses/e00fd5ec05d8024654aded2bce054b3014bd6560"}},"author_association":"OWNER"}}
{"actor":{"display_login":"kyessenov"}}