GitHub PullRequestReviewCommentEvent at 2014-10-23 07:54:56
Repository: contentful-management.js
Actor: grncdr
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/comments/19263397","id":19263397,"diff_hunk":"@@ -0,0 +1,52 @@\n+/**\n+ * Promise-based rate limiting of a function. Assumes that the passed in\n+ * function will return a Promise.\n+ */\n+'use strict';\n+\n+var Promise = require('bluebird');\n+\n+module.exports = function (count, delay, fn) {\n+  count = parseInt(count, 10);\n+  if (isNaN(count) || count < 1) {\n+    throw new TypeError('count must be greater than 0');\n+  }\n+\n+  var sem = count;\n+  var callQueue = [];\n+\n+  function shift () {\n+    if (sem < 1) {\n+      return;\n+    }\n+    var call = callQueue.shift();\n+    if (call) {\n+      sem--;\n+\n+      try {\n+        call.resolve(fn.apply(call.self, call.args).finally(shift));\n+      } catch (err) {\n+        call.reject(err);\n+      }\n+\n+      setTimeout(function () {\n+        sem++;","path":"rate-limit.js","position":33,"original_position":33,"commit_id":"b74ae77750054eedfac39dba13a92b2cb7e2342c","original_commit_id":"b74ae77750054eedfac39dba13a92b2cb7e2342c","user":{"login":"grncdr","id":82634,"avatar_url":"https://avatars.githubusercontent.com/u/82634?v=2","gravatar_id":"","url":"https://api.github.com/users/grncdr","html_url":"https://github.com/grncdr","followers_url":"https://api.github.com/users/grncdr/followers","following_url":"https://api.github.com/users/grncdr/following{/other_user}","gists_url":"https://api.github.com/users/grncdr/gists{/gist_id}","starred_url":"https://api.github.com/users/grncdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grncdr/subscriptions","organizations_url":"https://api.github.com/users/grncdr/orgs","repos_url":"https://api.github.com/users/grncdr/repos","events_url":"https://api.github.com/users/grncdr/events{/privacy}","received_events_url":"https://api.github.com/users/grncdr/received_events","type":"User","site_admin":false},"body":"The intent is that when we make a request, we are using up one of our \"tokens\" (tracked by the semaphore) and we can't re-use that token until `delay` time later. E.g. if I make a 10 requests in parallel, I'm not going to be allowed another request until `firstRequestTime + delay`.","created_at":"2014-10-23T07:54:56Z","updated_at":"2014-10-23T07:54:56Z","html_url":"https://github.com/contentful/contentful-management.js/pull/6#discussion_r19263397","pull_request_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/comments/19263397"},"html":{"href":"https://github.com/contentful/contentful-management.js/pull/6#discussion_r19263397"},"pull_request":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6","id":16049318,"html_url":"https://github.com/contentful/contentful-management.js/pull/6","diff_url":"https://github.com/contentful/contentful-management.js/pull/6.diff","patch_url":"https://github.com/contentful/contentful-management.js/pull/6.patch","issue_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/6","number":6,"state":"open","locked":false,"title":"Rate-limit requests","user":{"login":"grncdr","id":82634,"avatar_url":"https://avatars.githubusercontent.com/u/82634?v=2","gravatar_id":"","url":"https://api.github.com/users/grncdr","html_url":"https://github.com/grncdr","followers_url":"https://api.github.com/users/grncdr/followers","following_url":"https://api.github.com/users/grncdr/following{/other_user}","gists_url":"https://api.github.com/users/grncdr/gists{/gist_id}","starred_url":"https://api.github.com/users/grncdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grncdr/subscriptions","organizations_url":"https://api.github.com/users/grncdr/orgs","repos_url":"https://api.github.com/users/grncdr/repos","events_url":"https://api.github.com/users/grncdr/events{/privacy}","received_events_url":"https://api.github.com/users/grncdr/received_events","type":"User","site_admin":false},"body":"Also automatically retries requests that were rate-limited","created_at":"2014-05-19T11:48:01Z","updated_at":"2014-10-23T07:54:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97e97104437c9b23ff2b3163be590b65a99154b2","assignee":{"login":"sdepold","id":79163,"avatar_url":"https://avatars.githubusercontent.com/u/79163?v=2","gravatar_id":"","url":"https://api.github.com/users/sdepold","html_url":"https://github.com/sdepold","followers_url":"https://api.github.com/users/sdepold/followers","following_url":"https://api.github.com/users/sdepold/following{/other_user}","gists_url":"https://api.github.com/users/sdepold/gists{/gist_id}","starred_url":"https://api.github.com/users/sdepold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdepold/subscriptions","organizations_url":"https://api.github.com/users/sdepold/orgs","repos_url":"https://api.github.com/users/sdepold/repos","events_url":"https://api.github.com/users/sdepold/events{/privacy}","received_events_url":"https://api.github.com/users/sdepold/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6/commits","review_comments_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6/comments","review_comment_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls/comments/{number}","comments_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/6/comments","statuses_url":"https://api.github.com/repos/contentful/contentful-management.js/statuses/b74ae77750054eedfac39dba13a92b2cb7e2342c","head":{"label":"contentful:rate-limit","ref":"rate-limit","sha":"b74ae77750054eedfac39dba13a92b2cb7e2342c","user":{"login":"contentful","id":472182,"avatar_url":"https://avatars.githubusercontent.com/u/472182?v=2","gravatar_id":"","url":"https://api.github.com/users/contentful","html_url":"https://github.com/contentful","followers_url":"https://api.github.com/users/contentful/followers","following_url":"https://api.github.com/users/contentful/following{/other_user}","gists_url":"https://api.github.com/users/contentful/gists{/gist_id}","starred_url":"https://api.github.com/users/contentful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contentful/subscriptions","organizations_url":"https://api.github.com/users/contentful/orgs","repos_url":"https://api.github.com/users/contentful/repos","events_url":"https://api.github.com/users/contentful/events{/privacy}","received_events_url":"https://api.github.com/users/contentful/received_events","type":"Organization","site_admin":false},"repo":{"id":13154482,"name":"contentful-management.js","full_name":"contentful/contentful-management.js","owner":{"login":"contentful","id":472182,"avatar_url":"https://avatars.githubusercontent.com/u/472182?v=2","gravatar_id":"","url":"https://api.github.com/users/contentful","html_url":"https://github.com/contentful","followers_url":"https://api.github.com/users/contentful/followers","following_url":"https://api.github.com/users/contentful/following{/other_user}","gists_url":"https://api.github.com/users/contentful/gists{/gist_id}","starred_url":"https://api.github.com/users/contentful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contentful/subscriptions","organizations_url":"https://api.github.com/users/contentful/orgs","repos_url":"https://api.github.com/users/contentful/repos","events_url":"https://api.github.com/users/contentful/events{/privacy}","received_events_url":"https://api.github.com/users/contentful/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/contentful/contentful-management.js","description":"JavaScript library for Contentful's Management API (node & browser)","fork":false,"url":"https://api.github.com/repos/contentful/contentful-management.js","forks_url":"https://api.github.com/repos/contentful/contentful-management.js/forks","keys_url":"https://api.github.com/repos/contentful/contentful-management.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/contentful/contentful-management.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/contentful/contentful-management.js/teams","hooks_url":"https://api.github.com/repos/contentful/contentful-management.js/hooks","issue_events_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/events{/number}","events_url":"https://api.github.com/repos/contentful/contentful-management.js/events","assignees_url":"https://api.github.com/repos/contentful/contentful-management.js/assignees{/user}","branches_url":"https://api.github.com/repos/contentful/contentful-management.js/branches{/branch}","tags_url":"https://api.github.com/repos/contentful/contentful-management.js/tags","blobs_url":"https://api.github.com/repos/contentful/contentful-management.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/contentful/contentful-management.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/contentful/contentful-management.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/contentful/contentful-management.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/contentful/contentful-management.js/statuses/{sha}","languages_url":"https://api.github.com/repos/contentful/contentful-management.js/languages","stargazers_url":"https://api.github.com/repos/contentful/contentful-management.js/stargazers","contributors_url":"https://api.github.com/repos/contentful/contentful-management.js/contributors","subscribers_url":"https://api.github.com/repos/contentful/contentful-management.js/subscribers","subscription_url":"https://api.github.com/repos/contentful/contentful-management.js/subscription","commits_url":"https://api.github.com/repos/contentful/contentful-management.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/contentful/contentful-management.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/contentful/contentful-management.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/contentful/contentful-management.js/contents/{+path}","compare_url":"https://api.github.com/repos/contentful/contentful-management.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/contentful/contentful-management.js/merges","archive_url":"https://api.github.com/repos/contentful/contentful-management.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/contentful/contentful-management.js/downloads","issues_url":"https://api.github.com/repos/contentful/contentful-management.js/issues{/number}","pulls_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls{/number}","milestones_url":"https://api.github.com/repos/contentful/contentful-management.js/milestones{/number}","notifications_url":"https://api.github.com/repos/contentful/contentful-management.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/contentful/contentful-management.js/labels{/name}","releases_url":"https://api.github.com/repos/contentful/contentful-management.js/releases{/id}","created_at":"2013-09-27T15:45:29Z","updated_at":"2014-10-17T21:10:24Z","pushed_at":"2014-10-22T16:41:04Z","git_url":"git://github.com/contentful/contentful-management.js.git","ssh_url":"git@github.com:contentful/contentful-management.js.git","clone_url":"https://github.com/contentful/contentful-management.js.git","svn_url":"https://github.com/contentful/contentful-management.js","homepage":"https://www.contentful.com/developers/documentation/content-management-api/","size":865,"stargazers_count":15,"watchers_count":15,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":15,"default_branch":"master"}},"base":{"label":"contentful:master","ref":"master","sha":"2d54fb1a2cdd7f88725acd579624103dfb97670e","user":{"login":"contentful","id":472182,"avatar_url":"https://avatars.githubusercontent.com/u/472182?v=2","gravatar_id":"","url":"https://api.github.com/users/contentful","html_url":"https://github.com/contentful","followers_url":"https://api.github.com/users/contentful/followers","following_url":"https://api.github.com/users/contentful/following{/other_user}","gists_url":"https://api.github.com/users/contentful/gists{/gist_id}","starred_url":"https://api.github.com/users/contentful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contentful/subscriptions","organizations_url":"https://api.github.com/users/contentful/orgs","repos_url":"https://api.github.com/users/contentful/repos","events_url":"https://api.github.com/users/contentful/events{/privacy}","received_events_url":"https://api.github.com/users/contentful/received_events","type":"Organization","site_admin":false},"repo":{"id":13154482,"name":"contentful-management.js","full_name":"contentful/contentful-management.js","owner":{"login":"contentful","id":472182,"avatar_url":"https://avatars.githubusercontent.com/u/472182?v=2","gravatar_id":"","url":"https://api.github.com/users/contentful","html_url":"https://github.com/contentful","followers_url":"https://api.github.com/users/contentful/followers","following_url":"https://api.github.com/users/contentful/following{/other_user}","gists_url":"https://api.github.com/users/contentful/gists{/gist_id}","starred_url":"https://api.github.com/users/contentful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contentful/subscriptions","organizations_url":"https://api.github.com/users/contentful/orgs","repos_url":"https://api.github.com/users/contentful/repos","events_url":"https://api.github.com/users/contentful/events{/privacy}","received_events_url":"https://api.github.com/users/contentful/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/contentful/contentful-management.js","description":"JavaScript library for Contentful's Management API (node & browser)","fork":false,"url":"https://api.github.com/repos/contentful/contentful-management.js","forks_url":"https://api.github.com/repos/contentful/contentful-management.js/forks","keys_url":"https://api.github.com/repos/contentful/contentful-management.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/contentful/contentful-management.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/contentful/contentful-management.js/teams","hooks_url":"https://api.github.com/repos/contentful/contentful-management.js/hooks","issue_events_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/events{/number}","events_url":"https://api.github.com/repos/contentful/contentful-management.js/events","assignees_url":"https://api.github.com/repos/contentful/contentful-management.js/assignees{/user}","branches_url":"https://api.github.com/repos/contentful/contentful-management.js/branches{/branch}","tags_url":"https://api.github.com/repos/contentful/contentful-management.js/tags","blobs_url":"https://api.github.com/repos/contentful/contentful-management.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/contentful/contentful-management.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/contentful/contentful-management.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/contentful/contentful-management.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/contentful/contentful-management.js/statuses/{sha}","languages_url":"https://api.github.com/repos/contentful/contentful-management.js/languages","stargazers_url":"https://api.github.com/repos/contentful/contentful-management.js/stargazers","contributors_url":"https://api.github.com/repos/contentful/contentful-management.js/contributors","subscribers_url":"https://api.github.com/repos/contentful/contentful-management.js/subscribers","subscription_url":"https://api.github.com/repos/contentful/contentful-management.js/subscription","commits_url":"https://api.github.com/repos/contentful/contentful-management.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/contentful/contentful-management.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/contentful/contentful-management.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/contentful/contentful-management.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/contentful/contentful-management.js/contents/{+path}","compare_url":"https://api.github.com/repos/contentful/contentful-management.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/contentful/contentful-management.js/merges","archive_url":"https://api.github.com/repos/contentful/contentful-management.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/contentful/contentful-management.js/downloads","issues_url":"https://api.github.com/repos/contentful/contentful-management.js/issues{/number}","pulls_url":"https://api.github.com/repos/contentful/contentful-management.js/pulls{/number}","milestones_url":"https://api.github.com/repos/contentful/contentful-management.js/milestones{/number}","notifications_url":"https://api.github.com/repos/contentful/contentful-management.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/contentful/contentful-management.js/labels{/name}","releases_url":"https://api.github.com/repos/contentful/contentful-management.js/releases{/id}","created_at":"2013-09-27T15:45:29Z","updated_at":"2014-10-17T21:10:24Z","pushed_at":"2014-10-22T16:41:04Z","git_url":"git://github.com/contentful/contentful-management.js.git","ssh_url":"git@github.com:contentful/contentful-management.js.git","clone_url":"https://github.com/contentful/contentful-management.js.git","svn_url":"https://github.com/contentful/contentful-management.js","homepage":"https://www.contentful.com/developers/documentation/content-management-api/","size":865,"stargazers_count":15,"watchers_count":15,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6"},"html":{"href":"https://github.com/contentful/contentful-management.js/pull/6"},"issue":{"href":"https://api.github.com/repos/contentful/contentful-management.js/issues/6"},"comments":{"href":"https://api.github.com/repos/contentful/contentful-management.js/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/contentful/contentful-management.js/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/contentful/contentful-management.js/statuses/b74ae77750054eedfac39dba13a92b2cb7e2342c"}}}}