{"action":"created","comment":{"url":"https://api.github.com/repos/zalando/skipper/pulls/comments/41379941","id":41379941,"diff_hunk":"@@ -0,0 +1,197 @@\n+package routing\n+\n+import (\n+\t\"fmt\"\n+\t\"github.com/zalando/skipper/eskip\"\n+\t\"github.com/zalando/skipper/filters\"\n+\t\"log\"\n+\t\"net/url\"\n+\t\"time\"\n+)\n+\n+type incomingType uint\n+\n+const (\n+\tincomingReset incomingType = iota\n+\tincomingUpdate\n+)\n+\n+type routeDefs map[string]*eskip.Route\n+\n+type incomingData struct {\n+\ttyp            incomingType\n+\tclient         DataClient\n+\tupsertedRoutes []*eskip.Route\n+\tdeletedIds     []string\n+}\n+\n+func receiveInitial(c DataClient, pollTimeout time.Duration, out chan<- *incomingData) {\n+\tfor {\n+\t\troutes, err := c.GetInitial()\n+\t\tif err != nil {\n+\t\t\tlog.Println(\"error while receiveing initial data;\", err)\n+\t\t\ttime.Sleep(pollTimeout)\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tout <- &incomingData{incomingReset, c, routes, nil}\n+\t\treturn\n+\t}\n+}\n+\n+func receiveUpdates(c DataClient, pollTimeout time.Duration, out chan<- *incomingData) {\n+\tfor {\n+\t\ttime.Sleep(pollTimeout)\n+\t\troutes, deletedIds, err := c.GetUpdate()\n+\t\tif err != nil {\n+\t\t\tlog.Println(\"error while receiving update;\", err)\n+\t\t\treturn\n+\t\t}\n+\n+\t\tif len(routes) > 0 || len(deletedIds) > 0 {\n+\t\t\tout <- &incomingData{incomingUpdate, c, routes, deletedIds}\n+\t\t}\n+\t}\n+}\n+\n+func receiveFromClient(c DataClient, pollTimeout time.Duration, out chan<- *incomingData) {\n+\tfor {\n+\t\treceiveInitial(c, pollTimeout, out)\n+\t\treceiveUpdates(c, pollTimeout, out)\n+\t}\n+}\n+\n+func applyIncoming(defs routeDefs, d *incomingData) routeDefs {\n+\tif d.typ == incomingReset || defs == nil {\n+\t\tdefs = make(routeDefs)\n+\t}\n+\n+\tif d.typ == incomingUpdate {\n+\t\tfor _, id := range d.deletedIds {\n+\t\t\tdelete(defs, id)\n+\t\t}\n+\t}\n+\n+\tif d.typ == incomingReset || d.typ == incomingUpdate {\n+\t\tfor _, def := range d.upsertedRoutes {\n+\t\t\tdefs[def.Id] = def","path":"routing/datasource.go","position":77,"original_position":77,"commit_id":"bf89ad8df63fe59c175684ee95b5b74e37682ada","original_commit_id":"bf89ad8df63fe59c175684ee95b5b74e37682ada","user":{"login":"mo-gr","id":95577,"avatar_url":"https://avatars.githubusercontent.com/u/95577?v=3","gravatar_id":"","url":"https://api.github.com/users/mo-gr","html_url":"https://github.com/mo-gr","followers_url":"https://api.github.com/users/mo-gr/followers","following_url":"https://api.github.com/users/mo-gr/following{/other_user}","gists_url":"https://api.github.com/users/mo-gr/gists{/gist_id}","starred_url":"https://api.github.com/users/mo-gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mo-gr/subscriptions","organizations_url":"https://api.github.com/users/mo-gr/orgs","repos_url":"https://api.github.com/users/mo-gr/repos","events_url":"https://api.github.com/users/mo-gr/events{/privacy}","received_events_url":"https://api.github.com/users/mo-gr/received_events","type":"User","site_admin":false},"body":"your code suggests, that refs could be nil (line 65), but here, you are assigning to it without checking. Can this break?","created_at":"2015-10-07T11:42:16Z","updated_at":"2015-10-07T11:42:16Z","html_url":"https://github.com/zalando/skipper/pull/13#discussion_r41379941","pull_request_url":"https://api.github.com/repos/zalando/skipper/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/zalando/skipper/pulls/comments/41379941"},"html":{"href":"https://github.com/zalando/skipper/pull/13#discussion_r41379941"},"pull_request":{"href":"https://api.github.com/repos/zalando/skipper/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/zalando/skipper/pulls/13","id":47005729,"html_url":"https://github.com/zalando/skipper/pull/13","diff_url":"https://github.com/zalando/skipper/pull/13.diff","patch_url":"https://github.com/zalando/skipper/pull/13.patch","issue_url":"https://api.github.com/repos/zalando/skipper/issues/13","number":13,"state":"open","locked":false,"title":"Release cleanup data client","user":{"login":"aryszka","id":733217,"avatar_url":"https://avatars.githubusercontent.com/u/733217?v=3","gravatar_id":"","url":"https://api.github.com/users/aryszka","html_url":"https://github.com/aryszka","followers_url":"https://api.github.com/users/aryszka/followers","following_url":"https://api.github.com/users/aryszka/following{/other_user}","gists_url":"https://api.github.com/users/aryszka/gists{/gist_id}","starred_url":"https://api.github.com/users/aryszka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aryszka/subscriptions","organizations_url":"https://api.github.com/users/aryszka/orgs","repos_url":"https://api.github.com/users/aryszka/repos","events_url":"https://api.github.com/users/aryszka/events{/privacy}","received_events_url":"https://api.github.com/users/aryszka/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-07T09:40:33Z","updated_at":"2015-10-07T11:42:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f2aef5a74422d1037ad37587c9e393e5a5d123b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zalando/skipper/pulls/13/commits","review_comments_url":"https://api.github.com/repos/zalando/skipper/pulls/13/comments","review_comment_url":"https://api.github.com/repos/zalando/skipper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zalando/skipper/issues/13/comments","statuses_url":"https://api.github.com/repos/zalando/skipper/statuses/bf89ad8df63fe59c175684ee95b5b74e37682ada","head":{"label":"zalando:release-cleanup-data-client","ref":"release-cleanup-data-client","sha":"bf89ad8df63fe59c175684ee95b5b74e37682ada","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":38812664,"name":"skipper","full_name":"zalando/skipper","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/skipper","description":"","fork":false,"url":"https://api.github.com/repos/zalando/skipper","forks_url":"https://api.github.com/repos/zalando/skipper/forks","keys_url":"https://api.github.com/repos/zalando/skipper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/skipper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/skipper/teams","hooks_url":"https://api.github.com/repos/zalando/skipper/hooks","issue_events_url":"https://api.github.com/repos/zalando/skipper/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/skipper/events","assignees_url":"https://api.github.com/repos/zalando/skipper/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/skipper/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/skipper/tags","blobs_url":"https://api.github.com/repos/zalando/skipper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/skipper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/skipper/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/skipper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/skipper/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/skipper/languages","stargazers_url":"https://api.github.com/repos/zalando/skipper/stargazers","contributors_url":"https://api.github.com/repos/zalando/skipper/contributors","subscribers_url":"https://api.github.com/repos/zalando/skipper/subscribers","subscription_url":"https://api.github.com/repos/zalando/skipper/subscription","commits_url":"https://api.github.com/repos/zalando/skipper/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/skipper/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/skipper/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/skipper/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/skipper/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/skipper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/skipper/merges","archive_url":"https://api.github.com/repos/zalando/skipper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/skipper/downloads","issues_url":"https://api.github.com/repos/zalando/skipper/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/skipper/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/skipper/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/skipper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/skipper/labels{/name}","releases_url":"https://api.github.com/repos/zalando/skipper/releases{/id}","created_at":"2015-07-09T09:54:40Z","updated_at":"2015-08-20T03:06:11Z","pushed_at":"2015-10-07T09:40:33Z","git_url":"git://github.com/zalando/skipper.git","ssh_url":"git@github.com:zalando/skipper.git","clone_url":"https://github.com/zalando/skipper.git","svn_url":"https://github.com/zalando/skipper","homepage":null,"size":2263,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"zalando:release-cleanup-review","ref":"release-cleanup-review","sha":"46c4654d75965e48e88be62d50a0297274e6c0fc","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":38812664,"name":"skipper","full_name":"zalando/skipper","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/skipper","description":"","fork":false,"url":"https://api.github.com/repos/zalando/skipper","forks_url":"https://api.github.com/repos/zalando/skipper/forks","keys_url":"https://api.github.com/repos/zalando/skipper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/skipper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/skipper/teams","hooks_url":"https://api.github.com/repos/zalando/skipper/hooks","issue_events_url":"https://api.github.com/repos/zalando/skipper/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/skipper/events","assignees_url":"https://api.github.com/repos/zalando/skipper/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/skipper/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/skipper/tags","blobs_url":"https://api.github.com/repos/zalando/skipper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/skipper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/skipper/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/skipper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/skipper/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/skipper/languages","stargazers_url":"https://api.github.com/repos/zalando/skipper/stargazers","contributors_url":"https://api.github.com/repos/zalando/skipper/contributors","subscribers_url":"https://api.github.com/repos/zalando/skipper/subscribers","subscription_url":"https://api.github.com/repos/zalando/skipper/subscription","commits_url":"https://api.github.com/repos/zalando/skipper/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/skipper/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/skipper/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/skipper/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/skipper/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/skipper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/skipper/merges","archive_url":"https://api.github.com/repos/zalando/skipper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/skipper/downloads","issues_url":"https://api.github.com/repos/zalando/skipper/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/skipper/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/skipper/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/skipper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/skipper/labels{/name}","releases_url":"https://api.github.com/repos/zalando/skipper/releases{/id}","created_at":"2015-07-09T09:54:40Z","updated_at":"2015-08-20T03:06:11Z","pushed_at":"2015-10-07T09:40:33Z","git_url":"git://github.com/zalando/skipper.git","ssh_url":"git@github.com:zalando/skipper.git","clone_url":"https://github.com/zalando/skipper.git","svn_url":"https://github.com/zalando/skipper","homepage":null,"size":2263,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zalando/skipper/pulls/13"},"html":{"href":"https://github.com/zalando/skipper/pull/13"},"issue":{"href":"https://api.github.com/repos/zalando/skipper/issues/13"},"comments":{"href":"https://api.github.com/repos/zalando/skipper/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/zalando/skipper/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/zalando/skipper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zalando/skipper/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/zalando/skipper/statuses/bf89ad8df63fe59c175684ee95b5b74e37682ada"}}}}