{"action":"created","comment":{"url":"https://api.github.com/repos/youtube/vitess/pulls/comments/39062031","id":39062031,"diff_hunk":"@@ -0,0 +1,279 @@\n+package vtgate\n+\n+import (\n+\t\"fmt\"\n+\t\"sort\"\n+\t\"strings\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\tlog \"github.com/golang/glog\"\n+\tpbq \"github.com/youtube/vitess/go/vt/proto/query\"\n+\tpbt \"github.com/youtube/vitess/go/vt/proto/topodata\"\n+\t\"github.com/youtube/vitess/go/vt/tabletserver/tabletconn\"\n+\t\"github.com/youtube/vitess/go/vt/topo\"\n+\t\"golang.org/x/net/context\"\n+)\n+\n+// AddrUpdate updates about an endpoint and whether it is up.\n+type AddrUpdate struct {\n+\tEndPoint *pbt.EndPoint\n+\tIsUp     bool\n+}\n+\n+// NewHealthCheck creates a new HealthCheck object.\n+func NewHealthCheck(endPoints []*pbt.EndPoint, addrUpdate <-chan *AddrUpdate, connTimeout time.Duration, retryDelay time.Duration) *HealthCheck {\n+\thc := &HealthCheck{\n+\t\taddrToConns: make(map[string]*healthCheckConn),\n+\t\ttargetToEPs: make(map[string]map[string]map[pbt.TabletType][]*pbt.EndPoint),\n+\t\tconnTimeout: connTimeout,\n+\t\tretryDelay:  retryDelay,\n+\t}\n+\thc.initConns(endPoints)\n+\tgo hc.onAddrUpdate(addrUpdate)\n+\treturn hc\n+}\n+\n+// HealthCheck performs health checking and notifies downstream components about any changes.\n+type HealthCheck struct {\n+\tmu          sync.RWMutex","path":"go/vt/vtgate/healthcheck.go","position":39,"original_position":39,"commit_id":"49d0db7147141649afe62420cd7b665280737d89","original_commit_id":"925b104e57753c68ad8af27ecac4324412725d58","user":{"login":"guoliang100","id":5091016,"avatar_url":"https://avatars.githubusercontent.com/u/5091016?v=3","gravatar_id":"","url":"https://api.github.com/users/guoliang100","html_url":"https://github.com/guoliang100","followers_url":"https://api.github.com/users/guoliang100/followers","following_url":"https://api.github.com/users/guoliang100/following{/other_user}","gists_url":"https://api.github.com/users/guoliang100/gists{/gist_id}","starred_url":"https://api.github.com/users/guoliang100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guoliang100/subscriptions","organizations_url":"https://api.github.com/users/guoliang100/orgs","repos_url":"https://api.github.com/users/guoliang100/repos","events_url":"https://api.github.com/users/guoliang100/events{/privacy}","received_events_url":"https://api.github.com/users/guoliang100/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2015-09-09T16:03:08Z","updated_at":"2015-09-09T16:03:08Z","html_url":"https://github.com/youtube/vitess/pull/1082#discussion_r39062031","pull_request_url":"https://api.github.com/repos/youtube/vitess/pulls/1082","_links":{"self":{"href":"https://api.github.com/repos/youtube/vitess/pulls/comments/39062031"},"html":{"href":"https://github.com/youtube/vitess/pull/1082#discussion_r39062031"},"pull_request":{"href":"https://api.github.com/repos/youtube/vitess/pulls/1082"}}},"pull_request":{"url":"https://api.github.com/repos/youtube/vitess/pulls/1082","id":44513246,"html_url":"https://github.com/youtube/vitess/pull/1082","diff_url":"https://github.com/youtube/vitess/pull/1082.diff","patch_url":"https://github.com/youtube/vitess/pull/1082.patch","issue_url":"https://api.github.com/repos/youtube/vitess/issues/1082","number":1082,"state":"open","locked":false,"title":"Implement health check module for the new endpoint management.","user":{"login":"guoliang100","id":5091016,"avatar_url":"https://avatars.githubusercontent.com/u/5091016?v=3","gravatar_id":"","url":"https://api.github.com/users/guoliang100","html_url":"https://github.com/guoliang100","followers_url":"https://api.github.com/users/guoliang100/followers","following_url":"https://api.github.com/users/guoliang100/following{/other_user}","gists_url":"https://api.github.com/users/guoliang100/gists{/gist_id}","starred_url":"https://api.github.com/users/guoliang100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guoliang100/subscriptions","organizations_url":"https://api.github.com/users/guoliang100/orgs","repos_url":"https://api.github.com/users/guoliang100/repos","events_url":"https://api.github.com/users/guoliang100/events{/privacy}","received_events_url":"https://api.github.com/users/guoliang100/received_events","type":"User","site_admin":false},"body":"@alainjobart @sougou \r\n\r\n[WIP] It contains the core function of performing health check.\r\nTODO: update downstream components about changes, and unit tests.","created_at":"2015-09-09T06:00:33Z","updated_at":"2015-09-09T16:03:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40143fcb222298765c060e8dc18f531092610432","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/youtube/vitess/pulls/1082/commits","review_comments_url":"https://api.github.com/repos/youtube/vitess/pulls/1082/comments","review_comment_url":"https://api.github.com/repos/youtube/vitess/pulls/comments{/number}","comments_url":"https://api.github.com/repos/youtube/vitess/issues/1082/comments","statuses_url":"https://api.github.com/repos/youtube/vitess/statuses/49d0db7147141649afe62420cd7b665280737d89","head":{"label":"youtube:vtgateconn","ref":"vtgateconn","sha":"49d0db7147141649afe62420cd7b665280737d89","user":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"repo":{"id":11008207,"name":"vitess","full_name":"youtube/vitess","owner":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/youtube/vitess","description":"vitess provides servers and tools which facilitate scaling of MySQL databases for large scale web services.","fork":false,"url":"https://api.github.com/repos/youtube/vitess","forks_url":"https://api.github.com/repos/youtube/vitess/forks","keys_url":"https://api.github.com/repos/youtube/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/youtube/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/youtube/vitess/teams","hooks_url":"https://api.github.com/repos/youtube/vitess/hooks","issue_events_url":"https://api.github.com/repos/youtube/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/youtube/vitess/events","assignees_url":"https://api.github.com/repos/youtube/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/youtube/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/youtube/vitess/tags","blobs_url":"https://api.github.com/repos/youtube/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/youtube/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/youtube/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/youtube/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/youtube/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/youtube/vitess/languages","stargazers_url":"https://api.github.com/repos/youtube/vitess/stargazers","contributors_url":"https://api.github.com/repos/youtube/vitess/contributors","subscribers_url":"https://api.github.com/repos/youtube/vitess/subscribers","subscription_url":"https://api.github.com/repos/youtube/vitess/subscription","commits_url":"https://api.github.com/repos/youtube/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/youtube/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/youtube/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/youtube/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/youtube/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/youtube/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/youtube/vitess/merges","archive_url":"https://api.github.com/repos/youtube/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/youtube/vitess/downloads","issues_url":"https://api.github.com/repos/youtube/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/youtube/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/youtube/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/youtube/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/youtube/vitess/labels{/name}","releases_url":"https://api.github.com/repos/youtube/vitess/releases{/id}","created_at":"2013-06-27T21:20:28Z","updated_at":"2015-09-09T12:40:38Z","pushed_at":"2015-09-09T15:41:25Z","git_url":"git://github.com/youtube/vitess.git","ssh_url":"git@github.com:youtube/vitess.git","clone_url":"https://github.com/youtube/vitess.git","svn_url":"https://github.com/youtube/vitess","homepage":null,"size":71601,"stargazers_count":2773,"watchers_count":2773,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":352,"mirror_url":null,"open_issues_count":16,"forks":352,"open_issues":16,"watchers":2773,"default_branch":"master"}},"base":{"label":"youtube:master","ref":"master","sha":"4de82fd04acc67f7edad34856b1b79cf93566340","user":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"repo":{"id":11008207,"name":"vitess","full_name":"youtube/vitess","owner":{"login":"youtube","id":4052902,"avatar_url":"https://avatars.githubusercontent.com/u/4052902?v=3","gravatar_id":"","url":"https://api.github.com/users/youtube","html_url":"https://github.com/youtube","followers_url":"https://api.github.com/users/youtube/followers","following_url":"https://api.github.com/users/youtube/following{/other_user}","gists_url":"https://api.github.com/users/youtube/gists{/gist_id}","starred_url":"https://api.github.com/users/youtube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youtube/subscriptions","organizations_url":"https://api.github.com/users/youtube/orgs","repos_url":"https://api.github.com/users/youtube/repos","events_url":"https://api.github.com/users/youtube/events{/privacy}","received_events_url":"https://api.github.com/users/youtube/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/youtube/vitess","description":"vitess provides servers and tools which facilitate scaling of MySQL databases for large scale web services.","fork":false,"url":"https://api.github.com/repos/youtube/vitess","forks_url":"https://api.github.com/repos/youtube/vitess/forks","keys_url":"https://api.github.com/repos/youtube/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/youtube/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/youtube/vitess/teams","hooks_url":"https://api.github.com/repos/youtube/vitess/hooks","issue_events_url":"https://api.github.com/repos/youtube/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/youtube/vitess/events","assignees_url":"https://api.github.com/repos/youtube/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/youtube/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/youtube/vitess/tags","blobs_url":"https://api.github.com/repos/youtube/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/youtube/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/youtube/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/youtube/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/youtube/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/youtube/vitess/languages","stargazers_url":"https://api.github.com/repos/youtube/vitess/stargazers","contributors_url":"https://api.github.com/repos/youtube/vitess/contributors","subscribers_url":"https://api.github.com/repos/youtube/vitess/subscribers","subscription_url":"https://api.github.com/repos/youtube/vitess/subscription","commits_url":"https://api.github.com/repos/youtube/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/youtube/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/youtube/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/youtube/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/youtube/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/youtube/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/youtube/vitess/merges","archive_url":"https://api.github.com/repos/youtube/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/youtube/vitess/downloads","issues_url":"https://api.github.com/repos/youtube/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/youtube/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/youtube/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/youtube/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/youtube/vitess/labels{/name}","releases_url":"https://api.github.com/repos/youtube/vitess/releases{/id}","created_at":"2013-06-27T21:20:28Z","updated_at":"2015-09-09T12:40:38Z","pushed_at":"2015-09-09T15:41:25Z","git_url":"git://github.com/youtube/vitess.git","ssh_url":"git@github.com:youtube/vitess.git","clone_url":"https://github.com/youtube/vitess.git","svn_url":"https://github.com/youtube/vitess","homepage":null,"size":71601,"stargazers_count":2773,"watchers_count":2773,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":352,"mirror_url":null,"open_issues_count":16,"forks":352,"open_issues":16,"watchers":2773,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/youtube/vitess/pulls/1082"},"html":{"href":"https://github.com/youtube/vitess/pull/1082"},"issue":{"href":"https://api.github.com/repos/youtube/vitess/issues/1082"},"comments":{"href":"https://api.github.com/repos/youtube/vitess/issues/1082/comments"},"review_comments":{"href":"https://api.github.com/repos/youtube/vitess/pulls/1082/comments"},"review_comment":{"href":"https://api.github.com/repos/youtube/vitess/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/youtube/vitess/pulls/1082/commits"},"statuses":{"href":"https://api.github.com/repos/youtube/vitess/statuses/49d0db7147141649afe62420cd7b665280737d89"}}}}