{"action":"opened","number":206,"pull_request":{"url":"https://api.github.com/repos/ironsmile/nedomi/pulls/206","id":53153393,"html_url":"https://github.com/ironsmile/nedomi/pull/206","diff_url":"https://github.com/ironsmile/nedomi/pull/206.diff","patch_url":"https://github.com/ironsmile/nedomi/pull/206.patch","issue_url":"https://api.github.com/repos/ironsmile/nedomi/issues/206","number":206,"state":"open","locked":false,"title":"reimplement throttle handler","user":{"login":"MStoykov","id":312246,"avatar_url":"https://avatars.githubusercontent.com/u/312246?v=3","gravatar_id":"","url":"https://api.github.com/users/MStoykov","html_url":"https://github.com/MStoykov","followers_url":"https://api.github.com/users/MStoykov/followers","following_url":"https://api.github.com/users/MStoykov/following{/other_user}","gists_url":"https://api.github.com/users/MStoykov/gists{/gist_id}","starred_url":"https://api.github.com/users/MStoykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MStoykov/subscriptions","organizations_url":"https://api.github.com/users/MStoykov/orgs","repos_url":"https://api.github.com/users/MStoykov/repos","events_url":"https://api.github.com/users/MStoykov/events{/privacy}","received_events_url":"https://api.github.com/users/MStoykov/received_events","type":"User","site_admin":false},"body":"the throttle handler reimplementation has one main strenght - it can use\r\nsendfile. Other benifits is that it removes a dependancy. I would also\r\nargue it's lighter runtime(don't quote me).\r\n\r\nIn order to use this we use the now new ThrottledWriter which records\r\nhow much bytes it has throttled at a given speed and tries to write as\r\nmuch as it can in order to get to the speed that is requested.\r\n\r\nThe reason why it's done in the timeoutConn instead of in the handler\r\ngiven that it requires the whole getting the correct connection for each\r\nrequest is:\r\nhttp.ResponseWriter.ReadFrom does os.Stat on each io.LimitedReader it\r\ngets. This adds up pretty quickly to hundred of thousands of os.Stat, which\r\nboth slow down the whole application, and make a lot of objects.\r\n\r\nGiven the fact that io.LimitedReader is the only way to limit the amount\r\nof data the sendfile sends at a time and there is no way to go around\r\nhttp.ResponseWriter.ReadFrom without Hijacking the connection, the\r\ncurrent solution emerged.\r\n\r\nAdditional benifit is that other handlers can now throttle as well.","created_at":"2015-12-09T17:47:01Z","updated_at":"2015-12-09T17:47:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ironsmile/nedomi/pulls/206/commits","review_comments_url":"https://api.github.com/repos/ironsmile/nedomi/pulls/206/comments","review_comment_url":"https://api.github.com/repos/ironsmile/nedomi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ironsmile/nedomi/issues/206/comments","statuses_url":"https://api.github.com/repos/ironsmile/nedomi/statuses/ca9b201b26d8fdb159585f4894f9e6536e7e15ee","head":{"label":"ironsmile:feature/reimplementThrottle","ref":"feature/reimplementThrottle","sha":"ca9b201b26d8fdb159585f4894f9e6536e7e15ee","user":{"login":"ironsmile","id":50431,"avatar_url":"https://avatars.githubusercontent.com/u/50431?v=3","gravatar_id":"","url":"https://api.github.com/users/ironsmile","html_url":"https://github.com/ironsmile","followers_url":"https://api.github.com/users/ironsmile/followers","following_url":"https://api.github.com/users/ironsmile/following{/other_user}","gists_url":"https://api.github.com/users/ironsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/ironsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironsmile/subscriptions","organizations_url":"https://api.github.com/users/ironsmile/orgs","repos_url":"https://api.github.com/users/ironsmile/repos","events_url":"https://api.github.com/users/ironsmile/events{/privacy}","received_events_url":"https://api.github.com/users/ironsmile/received_events","type":"User","site_admin":false},"repo":{"id":29851193,"name":"nedomi","full_name":"ironsmile/nedomi","owner":{"login":"ironsmile","id":50431,"avatar_url":"https://avatars.githubusercontent.com/u/50431?v=3","gravatar_id":"","url":"https://api.github.com/users/ironsmile","html_url":"https://github.com/ironsmile","followers_url":"https://api.github.com/users/ironsmile/followers","following_url":"https://api.github.com/users/ironsmile/following{/other_user}","gists_url":"https://api.github.com/users/ironsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/ironsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironsmile/subscriptions","organizations_url":"https://api.github.com/users/ironsmile/orgs","repos_url":"https://api.github.com/users/ironsmile/repos","events_url":"https://api.github.com/users/ironsmile/events{/privacy}","received_events_url":"https://api.github.com/users/ironsmile/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ironsmile/nedomi","description":"HTTP media cache server","fork":false,"url":"https://api.github.com/repos/ironsmile/nedomi","forks_url":"https://api.github.com/repos/ironsmile/nedomi/forks","keys_url":"https://api.github.com/repos/ironsmile/nedomi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ironsmile/nedomi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ironsmile/nedomi/teams","hooks_url":"https://api.github.com/repos/ironsmile/nedomi/hooks","issue_events_url":"https://api.github.com/repos/ironsmile/nedomi/issues/events{/number}","events_url":"https://api.github.com/repos/ironsmile/nedomi/events","assignees_url":"https://api.github.com/repos/ironsmile/nedomi/assignees{/user}","branches_url":"https://api.github.com/repos/ironsmile/nedomi/branches{/branch}","tags_url":"https://api.github.com/repos/ironsmile/nedomi/tags","blobs_url":"https://api.github.com/repos/ironsmile/nedomi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ironsmile/nedomi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ironsmile/nedomi/git/refs{/sha}","trees_url":"https://api.github.com/repos/ironsmile/nedomi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ironsmile/nedomi/statuses/{sha}","languages_url":"https://api.github.com/repos/ironsmile/nedomi/languages","stargazers_url":"https://api.github.com/repos/ironsmile/nedomi/stargazers","contributors_url":"https://api.github.com/repos/ironsmile/nedomi/contributors","subscribers_url":"https://api.github.com/repos/ironsmile/nedomi/subscribers","subscription_url":"https://api.github.com/repos/ironsmile/nedomi/subscription","commits_url":"https://api.github.com/repos/ironsmile/nedomi/commits{/sha}","git_commits_url":"https://api.github.com/repos/ironsmile/nedomi/git/commits{/sha}","comments_url":"https://api.github.com/repos/ironsmile/nedomi/comments{/number}","issue_comment_url":"https://api.github.com/repos/ironsmile/nedomi/issues/comments{/number}","contents_url":"https://api.github.com/repos/ironsmile/nedomi/contents/{+path}","compare_url":"https://api.github.com/repos/ironsmile/nedomi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ironsmile/nedomi/merges","archive_url":"https://api.github.com/repos/ironsmile/nedomi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ironsmile/nedomi/downloads","issues_url":"https://api.github.com/repos/ironsmile/nedomi/issues{/number}","pulls_url":"https://api.github.com/repos/ironsmile/nedomi/pulls{/number}","milestones_url":"https://api.github.com/repos/ironsmile/nedomi/milestones{/number}","notifications_url":"https://api.github.com/repos/ironsmile/nedomi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ironsmile/nedomi/labels{/name}","releases_url":"https://api.github.com/repos/ironsmile/nedomi/releases{/id}","created_at":"2015-01-26T08:06:40Z","updated_at":"2015-10-28T12:00:44Z","pushed_at":"2015-12-09T17:46:48Z","git_url":"git://github.com/ironsmile/nedomi.git","ssh_url":"git@github.com:ironsmile/nedomi.git","clone_url":"https://github.com/ironsmile/nedomi.git","svn_url":"https://github.com/ironsmile/nedomi","homepage":"","size":1114,"stargazers_count":8,"watchers_count":8,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":18,"forks":5,"open_issues":18,"watchers":8,"default_branch":"master"}},"base":{"label":"ironsmile:master","ref":"master","sha":"dbfd190288b2d99147c6469d831b1e8000b6d54e","user":{"login":"ironsmile","id":50431,"avatar_url":"https://avatars.githubusercontent.com/u/50431?v=3","gravatar_id":"","url":"https://api.github.com/users/ironsmile","html_url":"https://github.com/ironsmile","followers_url":"https://api.github.com/users/ironsmile/followers","following_url":"https://api.github.com/users/ironsmile/following{/other_user}","gists_url":"https://api.github.com/users/ironsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/ironsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironsmile/subscriptions","organizations_url":"https://api.github.com/users/ironsmile/orgs","repos_url":"https://api.github.com/users/ironsmile/repos","events_url":"https://api.github.com/users/ironsmile/events{/privacy}","received_events_url":"https://api.github.com/users/ironsmile/received_events","type":"User","site_admin":false},"repo":{"id":29851193,"name":"nedomi","full_name":"ironsmile/nedomi","owner":{"login":"ironsmile","id":50431,"avatar_url":"https://avatars.githubusercontent.com/u/50431?v=3","gravatar_id":"","url":"https://api.github.com/users/ironsmile","html_url":"https://github.com/ironsmile","followers_url":"https://api.github.com/users/ironsmile/followers","following_url":"https://api.github.com/users/ironsmile/following{/other_user}","gists_url":"https://api.github.com/users/ironsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/ironsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironsmile/subscriptions","organizations_url":"https://api.github.com/users/ironsmile/orgs","repos_url":"https://api.github.com/users/ironsmile/repos","events_url":"https://api.github.com/users/ironsmile/events{/privacy}","received_events_url":"https://api.github.com/users/ironsmile/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ironsmile/nedomi","description":"HTTP media cache server","fork":false,"url":"https://api.github.com/repos/ironsmile/nedomi","forks_url":"https://api.github.com/repos/ironsmile/nedomi/forks","keys_url":"https://api.github.com/repos/ironsmile/nedomi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ironsmile/nedomi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ironsmile/nedomi/teams","hooks_url":"https://api.github.com/repos/ironsmile/nedomi/hooks","issue_events_url":"https://api.github.com/repos/ironsmile/nedomi/issues/events{/number}","events_url":"https://api.github.com/repos/ironsmile/nedomi/events","assignees_url":"https://api.github.com/repos/ironsmile/nedomi/assignees{/user}","branches_url":"https://api.github.com/repos/ironsmile/nedomi/branches{/branch}","tags_url":"https://api.github.com/repos/ironsmile/nedomi/tags","blobs_url":"https://api.github.com/repos/ironsmile/nedomi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ironsmile/nedomi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ironsmile/nedomi/git/refs{/sha}","trees_url":"https://api.github.com/repos/ironsmile/nedomi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ironsmile/nedomi/statuses/{sha}","languages_url":"https://api.github.com/repos/ironsmile/nedomi/languages","stargazers_url":"https://api.github.com/repos/ironsmile/nedomi/stargazers","contributors_url":"https://api.github.com/repos/ironsmile/nedomi/contributors","subscribers_url":"https://api.github.com/repos/ironsmile/nedomi/subscribers","subscription_url":"https://api.github.com/repos/ironsmile/nedomi/subscription","commits_url":"https://api.github.com/repos/ironsmile/nedomi/commits{/sha}","git_commits_url":"https://api.github.com/repos/ironsmile/nedomi/git/commits{/sha}","comments_url":"https://api.github.com/repos/ironsmile/nedomi/comments{/number}","issue_comment_url":"https://api.github.com/repos/ironsmile/nedomi/issues/comments{/number}","contents_url":"https://api.github.com/repos/ironsmile/nedomi/contents/{+path}","compare_url":"https://api.github.com/repos/ironsmile/nedomi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ironsmile/nedomi/merges","archive_url":"https://api.github.com/repos/ironsmile/nedomi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ironsmile/nedomi/downloads","issues_url":"https://api.github.com/repos/ironsmile/nedomi/issues{/number}","pulls_url":"https://api.github.com/repos/ironsmile/nedomi/pulls{/number}","milestones_url":"https://api.github.com/repos/ironsmile/nedomi/milestones{/number}","notifications_url":"https://api.github.com/repos/ironsmile/nedomi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ironsmile/nedomi/labels{/name}","releases_url":"https://api.github.com/repos/ironsmile/nedomi/releases{/id}","created_at":"2015-01-26T08:06:40Z","updated_at":"2015-10-28T12:00:44Z","pushed_at":"2015-12-09T17:46:48Z","git_url":"git://github.com/ironsmile/nedomi.git","ssh_url":"git@github.com:ironsmile/nedomi.git","clone_url":"https://github.com/ironsmile/nedomi.git","svn_url":"https://github.com/ironsmile/nedomi","homepage":"","size":1114,"stargazers_count":8,"watchers_count":8,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":18,"forks":5,"open_issues":18,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ironsmile/nedomi/pulls/206"},"html":{"href":"https://github.com/ironsmile/nedomi/pull/206"},"issue":{"href":"https://api.github.com/repos/ironsmile/nedomi/issues/206"},"comments":{"href":"https://api.github.com/repos/ironsmile/nedomi/issues/206/comments"},"review_comments":{"href":"https://api.github.com/repos/ironsmile/nedomi/pulls/206/comments"},"review_comment":{"href":"https://api.github.com/repos/ironsmile/nedomi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ironsmile/nedomi/pulls/206/commits"},"statuses":{"href":"https://api.github.com/repos/ironsmile/nedomi/statuses/ca9b201b26d8fdb159585f4894f9e6536e7e15ee"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":582,"deletions":23,"changed_files":14}}