{"action":"closed","number":1100,"pull_request":{"url":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100","id":70081804,"html_url":"https://github.com/petkaantonov/bluebird/pull/1100","diff_url":"https://github.com/petkaantonov/bluebird/pull/1100.diff","patch_url":"https://github.com/petkaantonov/bluebird/pull/1100.patch","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1100","number":1100,"state":"closed","locked":false,"title":"Proposal: `Promise.concurrent(limit)` and `.concurrent(limit)`","user":{"login":"justsml","id":397632,"avatar_url":"https://avatars.githubusercontent.com/u/397632?v=3","gravatar_id":"","url":"https://api.github.com/users/justsml","html_url":"https://github.com/justsml","followers_url":"https://api.github.com/users/justsml/followers","following_url":"https://api.github.com/users/justsml/following{/other_user}","gists_url":"https://api.github.com/users/justsml/gists{/gist_id}","starred_url":"https://api.github.com/users/justsml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justsml/subscriptions","organizations_url":"https://api.github.com/users/justsml/orgs","repos_url":"https://api.github.com/users/justsml/repos","events_url":"https://api.github.com/users/justsml/events{/privacy}","received_events_url":"https://api.github.com/users/justsml/received_events","type":"User","site_admin":false},"body":"## Preface\r\nI know concurrency has always been an awkward, if mostly misunderstood feature. (You can't necessarily control how many threads your OS or DB are spinning on. But the importance of being able to **limit the parallel execution of given sub-tasks** is immensely useful ESPECIALLY when you don't want to contend with other system resource. Potentially exhausting resources and leaving everything feeling unresponsive.\r\n\r\n## Use Case\r\nI typically configure a `concurrency` limit in my apps to between 2-6 cores - on my 24-core server. I know the sum of **actual spinning threads will exceed** the configured limit, as NodeJS/V8 has it's own background threads, I/O, etc. \r\n**Without any limits** set, I quickly end up with an **unpredictable & unstable server.**\r\n\r\n## Proposed Update\r\n\r\nAdd `Promise.concurrent(limit)` and `.concurrent(limit)` to make the interface more similar to `Promise.delay()` and `Promise.timeout()` \r\nThe expanded API to provide an alternative to `.map(fn, {concurrency: limit})` is also harder to mis-configure or overlook.\r\n\r\n## Example\r\n\r\nI've included documentation & updated tests. \r\n\r\nAn example adapted from one of my projects looks like this:\r\n\r\n```js\r\nvar leadData = Promise\r\n    .resolve(fetch('/leads'))\r\n    .concurrency(4)\r\n    .map(lead => {//<- Parallel map (4x)\r\n        return {\r\n            messages: getMessages(lead),\r\n            stats: getStats(lead)\r\n        }\r\n    })\r\n    .concurrency(8)\r\n    .filter(leadData => leadData.messages.length >= 1)//<- Highly parallel (8x)\r\n    .concurrency(1)\r\n    .map(leadData => addToTable(leadData))//<- Not parallel, UI bound (1x)\r\n```\r\n\r\nPlease let me know if I missed anything or if you have suggestions!\r\n\r\nThanks in advance!!!\r\n\r\n- Dan L.","created_at":"2016-05-14T04:25:05Z","updated_at":"2016-05-17T06:09:09Z","closed_at":"2016-05-17T06:09:09Z","merged_at":null,"merge_commit_sha":"dc64057d39179a7fa48163d40d3f01a31376e90a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100/commits","review_comments_url":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100/comments","review_comment_url":"https://api.github.com/repos/petkaantonov/bluebird/pulls/comments{/number}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1100/comments","statuses_url":"https://api.github.com/repos/petkaantonov/bluebird/statuses/61d9d79c8c52c1a973d3b4012df79f3a4efbef28","head":{"label":"justsml:concurrent","ref":"concurrent","sha":"61d9d79c8c52c1a973d3b4012df79f3a4efbef28","user":{"login":"justsml","id":397632,"avatar_url":"https://avatars.githubusercontent.com/u/397632?v=3","gravatar_id":"","url":"https://api.github.com/users/justsml","html_url":"https://github.com/justsml","followers_url":"https://api.github.com/users/justsml/followers","following_url":"https://api.github.com/users/justsml/following{/other_user}","gists_url":"https://api.github.com/users/justsml/gists{/gist_id}","starred_url":"https://api.github.com/users/justsml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justsml/subscriptions","organizations_url":"https://api.github.com/users/justsml/orgs","repos_url":"https://api.github.com/users/justsml/repos","events_url":"https://api.github.com/users/justsml/events{/privacy}","received_events_url":"https://api.github.com/users/justsml/received_events","type":"User","site_admin":false},"repo":{"id":50966476,"name":"bluebird","full_name":"justsml/bluebird","owner":{"login":"justsml","id":397632,"avatar_url":"https://avatars.githubusercontent.com/u/397632?v=3","gravatar_id":"","url":"https://api.github.com/users/justsml","html_url":"https://github.com/justsml","followers_url":"https://api.github.com/users/justsml/followers","following_url":"https://api.github.com/users/justsml/following{/other_user}","gists_url":"https://api.github.com/users/justsml/gists{/gist_id}","starred_url":"https://api.github.com/users/justsml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justsml/subscriptions","organizations_url":"https://api.github.com/users/justsml/orgs","repos_url":"https://api.github.com/users/justsml/repos","events_url":"https://api.github.com/users/justsml/events{/privacy}","received_events_url":"https://api.github.com/users/justsml/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/justsml/bluebird","description":"Bluebird is a full featured promise library with unmatched performance.","fork":true,"url":"https://api.github.com/repos/justsml/bluebird","forks_url":"https://api.github.com/repos/justsml/bluebird/forks","keys_url":"https://api.github.com/repos/justsml/bluebird/keys{/key_id}","collaborators_url":"https://api.github.com/repos/justsml/bluebird/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/justsml/bluebird/teams","hooks_url":"https://api.github.com/repos/justsml/bluebird/hooks","issue_events_url":"https://api.github.com/repos/justsml/bluebird/issues/events{/number}","events_url":"https://api.github.com/repos/justsml/bluebird/events","assignees_url":"https://api.github.com/repos/justsml/bluebird/assignees{/user}","branches_url":"https://api.github.com/repos/justsml/bluebird/branches{/branch}","tags_url":"https://api.github.com/repos/justsml/bluebird/tags","blobs_url":"https://api.github.com/repos/justsml/bluebird/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/justsml/bluebird/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/justsml/bluebird/git/refs{/sha}","trees_url":"https://api.github.com/repos/justsml/bluebird/git/trees{/sha}","statuses_url":"https://api.github.com/repos/justsml/bluebird/statuses/{sha}","languages_url":"https://api.github.com/repos/justsml/bluebird/languages","stargazers_url":"https://api.github.com/repos/justsml/bluebird/stargazers","contributors_url":"https://api.github.com/repos/justsml/bluebird/contributors","subscribers_url":"https://api.github.com/repos/justsml/bluebird/subscribers","subscription_url":"https://api.github.com/repos/justsml/bluebird/subscription","commits_url":"https://api.github.com/repos/justsml/bluebird/commits{/sha}","git_commits_url":"https://api.github.com/repos/justsml/bluebird/git/commits{/sha}","comments_url":"https://api.github.com/repos/justsml/bluebird/comments{/number}","issue_comment_url":"https://api.github.com/repos/justsml/bluebird/issues/comments{/number}","contents_url":"https://api.github.com/repos/justsml/bluebird/contents/{+path}","compare_url":"https://api.github.com/repos/justsml/bluebird/compare/{base}...{head}","merges_url":"https://api.github.com/repos/justsml/bluebird/merges","archive_url":"https://api.github.com/repos/justsml/bluebird/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/justsml/bluebird/downloads","issues_url":"https://api.github.com/repos/justsml/bluebird/issues{/number}","pulls_url":"https://api.github.com/repos/justsml/bluebird/pulls{/number}","milestones_url":"https://api.github.com/repos/justsml/bluebird/milestones{/number}","notifications_url":"https://api.github.com/repos/justsml/bluebird/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/justsml/bluebird/labels{/name}","releases_url":"https://api.github.com/repos/justsml/bluebird/releases{/id}","deployments_url":"https://api.github.com/repos/justsml/bluebird/deployments","created_at":"2016-02-03T01:59:52Z","updated_at":"2016-02-03T01:59:55Z","pushed_at":"2016-05-14T04:04:29Z","git_url":"git://github.com/justsml/bluebird.git","ssh_url":"git@github.com:justsml/bluebird.git","clone_url":"https://github.com/justsml/bluebird.git","svn_url":"https://github.com/justsml/bluebird","homepage":"http://bluebirdjs.com","size":12114,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"petkaantonov:master","ref":"master","sha":"c0d4472cecd523c2f9d4805a23d87be3cfe03b41","user":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"repo":{"id":12670444,"name":"bluebird","full_name":"petkaantonov/bluebird","owner":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/petkaantonov/bluebird","description":":bird: :zap: Bluebird is a full featured promise library with unmatched performance.","fork":false,"url":"https://api.github.com/repos/petkaantonov/bluebird","forks_url":"https://api.github.com/repos/petkaantonov/bluebird/forks","keys_url":"https://api.github.com/repos/petkaantonov/bluebird/keys{/key_id}","collaborators_url":"https://api.github.com/repos/petkaantonov/bluebird/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/petkaantonov/bluebird/teams","hooks_url":"https://api.github.com/repos/petkaantonov/bluebird/hooks","issue_events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/events{/number}","events_url":"https://api.github.com/repos/petkaantonov/bluebird/events","assignees_url":"https://api.github.com/repos/petkaantonov/bluebird/assignees{/user}","branches_url":"https://api.github.com/repos/petkaantonov/bluebird/branches{/branch}","tags_url":"https://api.github.com/repos/petkaantonov/bluebird/tags","blobs_url":"https://api.github.com/repos/petkaantonov/bluebird/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/petkaantonov/bluebird/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/petkaantonov/bluebird/git/refs{/sha}","trees_url":"https://api.github.com/repos/petkaantonov/bluebird/git/trees{/sha}","statuses_url":"https://api.github.com/repos/petkaantonov/bluebird/statuses/{sha}","languages_url":"https://api.github.com/repos/petkaantonov/bluebird/languages","stargazers_url":"https://api.github.com/repos/petkaantonov/bluebird/stargazers","contributors_url":"https://api.github.com/repos/petkaantonov/bluebird/contributors","subscribers_url":"https://api.github.com/repos/petkaantonov/bluebird/subscribers","subscription_url":"https://api.github.com/repos/petkaantonov/bluebird/subscription","commits_url":"https://api.github.com/repos/petkaantonov/bluebird/commits{/sha}","git_commits_url":"https://api.github.com/repos/petkaantonov/bluebird/git/commits{/sha}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/comments{/number}","issue_comment_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments{/number}","contents_url":"https://api.github.com/repos/petkaantonov/bluebird/contents/{+path}","compare_url":"https://api.github.com/repos/petkaantonov/bluebird/compare/{base}...{head}","merges_url":"https://api.github.com/repos/petkaantonov/bluebird/merges","archive_url":"https://api.github.com/repos/petkaantonov/bluebird/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/petkaantonov/bluebird/downloads","issues_url":"https://api.github.com/repos/petkaantonov/bluebird/issues{/number}","pulls_url":"https://api.github.com/repos/petkaantonov/bluebird/pulls{/number}","milestones_url":"https://api.github.com/repos/petkaantonov/bluebird/milestones{/number}","notifications_url":"https://api.github.com/repos/petkaantonov/bluebird/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/labels{/name}","releases_url":"https://api.github.com/repos/petkaantonov/bluebird/releases{/id}","deployments_url":"https://api.github.com/repos/petkaantonov/bluebird/deployments","created_at":"2013-09-07T19:39:57Z","updated_at":"2016-05-17T04:00:02Z","pushed_at":"2016-05-16T11:15:34Z","git_url":"git://github.com/petkaantonov/bluebird.git","ssh_url":"git@github.com:petkaantonov/bluebird.git","clone_url":"https://github.com/petkaantonov/bluebird.git","svn_url":"https://github.com/petkaantonov/bluebird","homepage":"http://bluebirdjs.com","size":15345,"stargazers_count":11019,"watchers_count":11019,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1284,"mirror_url":null,"open_issues_count":37,"forks":1284,"open_issues":37,"watchers":11019,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100"},"html":{"href":"https://github.com/petkaantonov/bluebird/pull/1100"},"issue":{"href":"https://api.github.com/repos/petkaantonov/bluebird/issues/1100"},"comments":{"href":"https://api.github.com/repos/petkaantonov/bluebird/issues/1100/comments"},"review_comments":{"href":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100/comments"},"review_comment":{"href":"https://api.github.com/repos/petkaantonov/bluebird/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/petkaantonov/bluebird/pulls/1100/commits"},"statuses":{"href":"https://api.github.com/repos/petkaantonov/bluebird/statuses/61d9d79c8c52c1a973d3b4012df79f3a4efbef28"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":8,"review_comments":0,"commits":8,"additions":304,"deletions":6,"changed_files":9}}