{"action":"created","comment":{"url":"https://api.github.com/repos/square/p2/pulls/comments/60335314","id":60335314,"diff_hunk":"@@ -193,6 +199,122 @@ func (s *consulStore) FindWhereLabeled(podID types.PodID,\n \treturn ret, nil\n }\n \n+// Watch watches the entire podClusterTree for changes.\n+// It will return a blocking channel on which the client can read\n+// WatchedPodCluster objects. The goroutine maintaining the watch will block on\n+// writing to this channel so it's up to the caller to read it with haste.\n+func (s *consulStore) Watch(quit <-chan struct{}) <-chan WatchedPodCluster {\n+\tinCh := make(chan api.KVPairs)\n+\toutCh := make(chan WatchedPodCluster)\n+\terrChan := make(chan error, 1)\n+\n+\tgo consulutil.WatchPrefix(podClusterTree, s.kv, inCh, quit, errChan)\n+\n+\tgo func() {\n+\t\tvar kvp api.KVPairs\n+\t\tfor {\n+\t\t\tselect {\n+\t\t\tcase <-quit:\n+\t\t\t\treturn\n+\t\t\tcase err := <-errChan:\n+\t\t\t\ts.logger.WithError(err).Errorf(\"WatchPrefix returned error, recovered.\")\n+\t\t\tcase kvp = <-inCh:\n+\t\t\t\tif kvp == nil {\n+\t\t\t\t\t// nothing to do\n+\t\t\t\t\tcontinue\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tpcs, err := kvpsToPC(kvp)\n+\t\t\tif err != nil {\n+\t\t\t\tselect {\n+\t\t\t\tcase <-quit:\n+\t\t\t\t\treturn\n+\t\t\t\tcase outCh <- WatchedPodCluster{PodCluster: nil, Err: err}:","path":"pkg/kp/pcstore/consul_store.go","position":86,"original_position":86,"commit_id":"8a2e1811319b1137fc6e2f1f493e2630d0243a6d","original_commit_id":"8a2e1811319b1137fc6e2f1f493e2630d0243a6d","user":{"login":"mpuncel","id":1444855,"avatar_url":"https://avatars.githubusercontent.com/u/1444855?v=3","gravatar_id":"","url":"https://api.github.com/users/mpuncel","html_url":"https://github.com/mpuncel","followers_url":"https://api.github.com/users/mpuncel/followers","following_url":"https://api.github.com/users/mpuncel/following{/other_user}","gists_url":"https://api.github.com/users/mpuncel/gists{/gist_id}","starred_url":"https://api.github.com/users/mpuncel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpuncel/subscriptions","organizations_url":"https://api.github.com/users/mpuncel/orgs","repos_url":"https://api.github.com/users/mpuncel/repos","events_url":"https://api.github.com/users/mpuncel/events{/privacy}","received_events_url":"https://api.github.com/users/mpuncel/received_events","type":"User","site_admin":false},"body":"might be nice to be explicit, but if `err != nil` then `pcs` is a 0 length slice so it's fine","created_at":"2016-04-20T00:31:56Z","updated_at":"2016-04-20T00:31:56Z","html_url":"https://github.com/square/p2/pull/469#discussion_r60335314","pull_request_url":"https://api.github.com/repos/square/p2/pulls/469","_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/comments/60335314"},"html":{"href":"https://github.com/square/p2/pull/469#discussion_r60335314"},"pull_request":{"href":"https://api.github.com/repos/square/p2/pulls/469"}}},"pull_request":{"url":"https://api.github.com/repos/square/p2/pulls/469","id":66714954,"html_url":"https://github.com/square/p2/pull/469","diff_url":"https://github.com/square/p2/pull/469.diff","patch_url":"https://github.com/square/p2/pull/469.patch","issue_url":"https://api.github.com/repos/square/p2/issues/469","number":469,"state":"open","locked":false,"title":"pcstore implements Watch()","user":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"body":"This is an early pass at implement Watch() for pcstore. It is explicitly missing a filter on the ID parameter inside of the watch function. I'm likely to do the naive thing unless someone suggests something more clever.","created_at":"2016-04-15T22:45:11Z","updated_at":"2016-04-20T00:31:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2c8c0686f0f18cc7bfe072ab678f5a83570b278","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/p2/pulls/469/commits","review_comments_url":"https://api.github.com/repos/square/p2/pulls/469/comments","review_comment_url":"https://api.github.com/repos/square/p2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/p2/issues/469/comments","statuses_url":"https://api.github.com/repos/square/p2/statuses/8a2e1811319b1137fc6e2f1f493e2630d0243a6d","head":{"label":"rudle:pod-cluster-watcher","ref":"pod-cluster-watcher","sha":"8a2e1811319b1137fc6e2f1f493e2630d0243a6d","user":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"repo":{"id":43720299,"name":"p2","full_name":"rudle/p2","owner":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rudle/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":true,"url":"https://api.github.com/repos/rudle/p2","forks_url":"https://api.github.com/repos/rudle/p2/forks","keys_url":"https://api.github.com/repos/rudle/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rudle/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rudle/p2/teams","hooks_url":"https://api.github.com/repos/rudle/p2/hooks","issue_events_url":"https://api.github.com/repos/rudle/p2/issues/events{/number}","events_url":"https://api.github.com/repos/rudle/p2/events","assignees_url":"https://api.github.com/repos/rudle/p2/assignees{/user}","branches_url":"https://api.github.com/repos/rudle/p2/branches{/branch}","tags_url":"https://api.github.com/repos/rudle/p2/tags","blobs_url":"https://api.github.com/repos/rudle/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rudle/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rudle/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/rudle/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rudle/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/rudle/p2/languages","stargazers_url":"https://api.github.com/repos/rudle/p2/stargazers","contributors_url":"https://api.github.com/repos/rudle/p2/contributors","subscribers_url":"https://api.github.com/repos/rudle/p2/subscribers","subscription_url":"https://api.github.com/repos/rudle/p2/subscription","commits_url":"https://api.github.com/repos/rudle/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/rudle/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/rudle/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/rudle/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/rudle/p2/contents/{+path}","compare_url":"https://api.github.com/repos/rudle/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rudle/p2/merges","archive_url":"https://api.github.com/repos/rudle/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rudle/p2/downloads","issues_url":"https://api.github.com/repos/rudle/p2/issues{/number}","pulls_url":"https://api.github.com/repos/rudle/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/rudle/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/rudle/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rudle/p2/labels{/name}","releases_url":"https://api.github.com/repos/rudle/p2/releases{/id}","deployments_url":"https://api.github.com/repos/rudle/p2/deployments","created_at":"2015-10-05T23:46:14Z","updated_at":"2016-01-21T18:20:01Z","pushed_at":"2016-04-20T00:22:46Z","git_url":"git://github.com/rudle/p2.git","ssh_url":"git@github.com:rudle/p2.git","clone_url":"https://github.com/rudle/p2.git","svn_url":"https://github.com/rudle/p2","homepage":"","size":33224,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"square:master","ref":"master","sha":"9d9e7f9348ed4bb4dc13ee2e343b71407100db12","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":25320424,"name":"p2","full_name":"square/p2","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":false,"url":"https://api.github.com/repos/square/p2","forks_url":"https://api.github.com/repos/square/p2/forks","keys_url":"https://api.github.com/repos/square/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/p2/teams","hooks_url":"https://api.github.com/repos/square/p2/hooks","issue_events_url":"https://api.github.com/repos/square/p2/issues/events{/number}","events_url":"https://api.github.com/repos/square/p2/events","assignees_url":"https://api.github.com/repos/square/p2/assignees{/user}","branches_url":"https://api.github.com/repos/square/p2/branches{/branch}","tags_url":"https://api.github.com/repos/square/p2/tags","blobs_url":"https://api.github.com/repos/square/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/square/p2/languages","stargazers_url":"https://api.github.com/repos/square/p2/stargazers","contributors_url":"https://api.github.com/repos/square/p2/contributors","subscribers_url":"https://api.github.com/repos/square/p2/subscribers","subscription_url":"https://api.github.com/repos/square/p2/subscription","commits_url":"https://api.github.com/repos/square/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/p2/contents/{+path}","compare_url":"https://api.github.com/repos/square/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/p2/merges","archive_url":"https://api.github.com/repos/square/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/p2/downloads","issues_url":"https://api.github.com/repos/square/p2/issues{/number}","pulls_url":"https://api.github.com/repos/square/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/square/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/square/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/p2/labels{/name}","releases_url":"https://api.github.com/repos/square/p2/releases{/id}","deployments_url":"https://api.github.com/repos/square/p2/deployments","created_at":"2014-10-16T20:31:12Z","updated_at":"2016-04-18T20:16:06Z","pushed_at":"2016-04-20T00:22:47Z","git_url":"git://github.com/square/p2.git","ssh_url":"git@github.com:square/p2.git","clone_url":"https://github.com/square/p2.git","svn_url":"https://github.com/square/p2","homepage":"","size":33425,"stargazers_count":103,"watchers_count":103,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":2,"forks":18,"open_issues":2,"watchers":103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/469"},"html":{"href":"https://github.com/square/p2/pull/469"},"issue":{"href":"https://api.github.com/repos/square/p2/issues/469"},"comments":{"href":"https://api.github.com/repos/square/p2/issues/469/comments"},"review_comments":{"href":"https://api.github.com/repos/square/p2/pulls/469/comments"},"review_comment":{"href":"https://api.github.com/repos/square/p2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/p2/pulls/469/commits"},"statuses":{"href":"https://api.github.com/repos/square/p2/statuses/8a2e1811319b1137fc6e2f1f493e2630d0243a6d"}}}}