{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/36809188","id":36809188,"diff_hunk":"@@ -0,0 +1,78 @@\n+package progressreader\n+\n+import (\n+\t\"bytes\"\n+\t\"io\"\n+\t\"sync\"\n+)\n+\n+// ProgressStatus keeps track of one or more observers watching the progress\n+// of an operation. For example, if multiple clients are trying to pull an\n+// image, they share a ProgressStatus for the download operation.\n+type ProgressStatus struct {\n+\tsync.Mutex\n+\t// c is a channel that observers block on, waiting for the operation\n+\t// to finish.\n+\tc chan struct{}\n+\t// observers is a list of io.Writers which receive a copy of the\n+\t// progress output.\n+\tobservers []io.Writer\n+\t// history is a buffer of the progress output so far, so a new observer\n+\t// can catch up.\n+\thistory bytes.Buffer\n+}\n+\n+// NewProgressStatus returns a ProgressStatus structure\n+func NewProgressStatus() *ProgressStatus {\n+\treturn &ProgressStatus{\n+\t\tc:         make(chan struct{}),\n+\t\tobservers: []io.Writer{},\n+\t}\n+}\n+\n+// Write adds data to the history buffer, and also writes it to all current\n+// observers.\n+func (ps *ProgressStatus) Write(p []byte) (n int, err error) {\n+\tps.Lock()\n+\tdefer ps.Unlock()\n+\tps.history.Write(p)\n+\tfor _, w := range ps.observers {\n+\t\t// copy paste from MultiWriter, replaced return with continue\n+\t\tn, err = w.Write(p)","path":"pkg/progressreader/progressstatus.go","position":41,"original_position":41,"commit_id":"903ba304efd5839c26cfeb8a8de73e2f03a15c01","original_commit_id":"903ba304efd5839c26cfeb8a8de73e2f03a15c01","user":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"body":"Would it be better to buffer data that writers can't keep up with, possibly indefinitely?","created_at":"2015-08-11T22:50:13Z","updated_at":"2015-08-11T22:50:13Z","html_url":"https://github.com/docker/docker/pull/15489#discussion_r36809188","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/15489","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/36809188"},"html":{"href":"https://github.com/docker/docker/pull/15489#discussion_r36809188"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/15489"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/15489","id":42155770,"html_url":"https://github.com/docker/docker/pull/15489","diff_url":"https://github.com/docker/docker/pull/15489.diff","patch_url":"https://github.com/docker/docker/pull/15489.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/15489","number":15489,"state":"open","locked":false,"title":"Show pull progress in terminal for inflight pull requests","user":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"body":"This PR incorporates @samsabed's work from #12874. It consists of his original commit, a merge to bring it up to date with master, and two cleanup commits written by me.\r\n\r\nThe text from the original PR is:\r\n\r\nShow pull progress when another client is also performing a same image pull request\r\nThis PR does it only on the pulled image level, and not layers, push\r\n\r\nFixes #8385\r\n\r\nMy additional commits:\r\n\r\n- Bring this code up to date with a merge (mostly moving code to the new pull_v1.go and pull_v2.go files)\r\n- Change poolAdd not to return both an error and other information at the same time\r\n- Document and clean up ProgressStatus","created_at":"2015-08-11T17:35:07Z","updated_at":"2015-08-11T22:50:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aea2f596d06c281a2174bc51f04573890b75138b","assignee":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/41","html_url":"https://github.com/docker/docker/milestones/1.9.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/41/labels","id":1211905,"number":41,"title":"1.9.0","description":"","creator":{"login":"dmp42","id":332946,"avatar_url":"https://avatars.githubusercontent.com/u/332946?v=3","gravatar_id":"","url":"https://api.github.com/users/dmp42","html_url":"https://github.com/dmp42","followers_url":"https://api.github.com/users/dmp42/followers","following_url":"https://api.github.com/users/dmp42/following{/other_user}","gists_url":"https://api.github.com/users/dmp42/gists{/gist_id}","starred_url":"https://api.github.com/users/dmp42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmp42/subscriptions","organizations_url":"https://api.github.com/users/dmp42/orgs","repos_url":"https://api.github.com/users/dmp42/repos","events_url":"https://api.github.com/users/dmp42/events{/privacy}","received_events_url":"https://api.github.com/users/dmp42/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":1,"state":"open","created_at":"2015-07-16T20:50:09Z","updated_at":"2015-08-11T21:23:28Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/docker/docker/pulls/15489/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/15489/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/15489/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/903ba304efd5839c26cfeb8a8de73e2f03a15c01","head":{"label":"aaronlehmann:pull-updates","ref":"pull-updates","sha":"903ba304efd5839c26cfeb8a8de73e2f03a15c01","user":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"repo":{"id":39463499,"name":"docker","full_name":"aaronlehmann/docker","owner":{"login":"aaronlehmann","id":10601430,"avatar_url":"https://avatars.githubusercontent.com/u/10601430?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronlehmann","html_url":"https://github.com/aaronlehmann","followers_url":"https://api.github.com/users/aaronlehmann/followers","following_url":"https://api.github.com/users/aaronlehmann/following{/other_user}","gists_url":"https://api.github.com/users/aaronlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronlehmann/subscriptions","organizations_url":"https://api.github.com/users/aaronlehmann/orgs","repos_url":"https://api.github.com/users/aaronlehmann/repos","events_url":"https://api.github.com/users/aaronlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/aaronlehmann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aaronlehmann/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/aaronlehmann/docker","forks_url":"https://api.github.com/repos/aaronlehmann/docker/forks","keys_url":"https://api.github.com/repos/aaronlehmann/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aaronlehmann/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aaronlehmann/docker/teams","hooks_url":"https://api.github.com/repos/aaronlehmann/docker/hooks","issue_events_url":"https://api.github.com/repos/aaronlehmann/docker/issues/events{/number}","events_url":"https://api.github.com/repos/aaronlehmann/docker/events","assignees_url":"https://api.github.com/repos/aaronlehmann/docker/assignees{/user}","branches_url":"https://api.github.com/repos/aaronlehmann/docker/branches{/branch}","tags_url":"https://api.github.com/repos/aaronlehmann/docker/tags","blobs_url":"https://api.github.com/repos/aaronlehmann/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aaronlehmann/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aaronlehmann/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/aaronlehmann/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aaronlehmann/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/aaronlehmann/docker/languages","stargazers_url":"https://api.github.com/repos/aaronlehmann/docker/stargazers","contributors_url":"https://api.github.com/repos/aaronlehmann/docker/contributors","subscribers_url":"https://api.github.com/repos/aaronlehmann/docker/subscribers","subscription_url":"https://api.github.com/repos/aaronlehmann/docker/subscription","commits_url":"https://api.github.com/repos/aaronlehmann/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/aaronlehmann/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/aaronlehmann/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/aaronlehmann/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/aaronlehmann/docker/contents/{+path}","compare_url":"https://api.github.com/repos/aaronlehmann/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aaronlehmann/docker/merges","archive_url":"https://api.github.com/repos/aaronlehmann/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aaronlehmann/docker/downloads","issues_url":"https://api.github.com/repos/aaronlehmann/docker/issues{/number}","pulls_url":"https://api.github.com/repos/aaronlehmann/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/aaronlehmann/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/aaronlehmann/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aaronlehmann/docker/labels{/name}","releases_url":"https://api.github.com/repos/aaronlehmann/docker/releases{/id}","created_at":"2015-07-21T18:44:59Z","updated_at":"2015-07-21T18:45:07Z","pushed_at":"2015-08-11T17:29:10Z","git_url":"git://github.com/aaronlehmann/docker.git","ssh_url":"git@github.com:aaronlehmann/docker.git","clone_url":"https://github.com/aaronlehmann/docker.git","svn_url":"https://github.com/aaronlehmann/docker","homepage":"http://www.docker.com","size":65576,"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":"docker:master","ref":"master","sha":"3e596da9eaa38e2f0d2778a896f3d566c96c70eb","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-08-11T22:32:05Z","pushed_at":"2015-08-11T22:33:19Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":237268,"stargazers_count":23905,"watchers_count":23905,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6063,"mirror_url":null,"open_issues_count":1065,"forks":6063,"open_issues":1065,"watchers":23905,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/15489"},"html":{"href":"https://github.com/docker/docker/pull/15489"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/15489"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/15489/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/15489/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/15489/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/903ba304efd5839c26cfeb8a8de73e2f03a15c01"}}}}