{"_id":"poolq","_rev":"8-5ec6fad6ce3a9b6938a7329ac811e234","name":"poolq","dist-tags":{"latest":"0.4.0"},"versions":{"0.2.0":{"name":"poolq","version":"0.2.0","author":{"name":"Steven Berry"},"license":"MIT","main":"main","dependencies":{"js-priority-queue":"^0.1.5"},"devDependencies":{"chai":"^4.0.2","chai-as-promised":"^6.0.0","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^3.0.1","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-read":"0.0.1","gulp-rename":"^1.2.2","gulp-tar":"^1.9.0","mocha":"^3.4.2","proxyquire":"^1.8.0","run-sequence":"^1.2.2","sinon":"^2.3.2","sinon-chai":"^2.10.0"},"gitHead":"ae5ceb84fd89e4308ec50e97bb1927654cbe2cfb","_id":"poolq@0.2.0","scripts":{},"_shasum":"e4b4dbc5a847e2f5007d7571b15262f0ac0d11bf","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"shasum":"e4b4dbc5a847e2f5007d7571b15262f0ac0d11bf","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.2.0.tgz","integrity":"sha512-te/+Mj6KazmIncodnbZDwQWm4Gk6J2fBQiaNy3ERM6iRKedYbMtB3gxQbsT+g5gQVSALPAq03X5F9nQGZDvzuA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCulz9WFbH2cZOTNn5zAlUwIXeJaeG80/QlS11PZ6XfowIgPycAydt97sLwoe7/XIcUhRxFppIwF6Y8efkVCsVrqFM="}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.2.0.tgz_1496751597181_0.25416795164346695"}},"0.1.0":{"name":"poolq","version":"0.1.0","author":{"name":"Steven Berry"},"license":"MIT","main":"main","dependencies":{"bluebird":"^3.3.5","js-priority-queue":"^0.1.5","lodash":"^4.12.0","node-noop":"^1.0.0"},"devDependencies":{"chai":"^4.0.2","chai-as-promised":"^6.0.0","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^3.0.1","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-read":"0.0.1","gulp-rename":"^1.2.2","gulp-tar":"^1.9.0","mocha":"^3.4.2","proxyquire":"^1.8.0","run-sequence":"^1.2.2","sinon":"^2.3.2","sinon-chai":"^2.10.0"},"gitHead":"3d08203323a19490b31d6ba83bec29508a9eeb51","_id":"poolq@0.1.0","scripts":{},"_shasum":"9f99c320969ba303f6c9e79fe679433608684cfc","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"shasum":"9f99c320969ba303f6c9e79fe679433608684cfc","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.1.0.tgz","integrity":"sha512-tTf2BCPgxX40GXXdTamKP1jdi24dZydaaBWOhYWb+xemfOqJ33+HZB/W7sFVNP7ejSCMY5PFgqsV/rZCHHD4uQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICis1SV/mvHDIEmk+PqT1l9oluAKJSVaOEv4ufAFG2dWAiA4suM4wmIzy8LBrH5UrMa7s0q7w0PQTEHI4fLoXX5YwA=="}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.1.0.tgz_1496751620331_0.8373074368573725"}},"0.3.0":{"name":"poolq","version":"0.3.0","author":{"name":"Steven Berry"},"license":"MIT","main":"main","dependencies":{"js-priority-queue":"^0.1.5"},"devDependencies":{"chai":"^4.0.2","chai-as-promised":"^6.0.0","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^3.0.1","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-read":"0.0.1","gulp-rename":"^1.2.2","gulp-tar":"^1.9.0","mocha":"^3.4.2","proxyquire":"^1.8.0","run-sequence":"^1.2.2","sinon":"^2.3.2","sinon-chai":"^2.10.0"},"gitHead":"3584d5be145e63816914ef8c3f1ce222c4c2eed9","_id":"poolq@0.3.0","_npmVersion":"5.4.0","_nodeVersion":"8.3.0","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"integrity":"sha512-L3jiPAZT1mmygE1x75J2rh5weF98ibJf4R3lC/gR5gkiJhzEBAtWhGE0V4iifrPTXtaOuX1TTz2RtdAjQuF9iA==","shasum":"ffa9f5e7df77d8f282e99c567e334b815b73d57f","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.3.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDWPzCR28dICjUGdkCAc6GfJR86pp/mCUkDiin9NnlcmgIhALA5U/my2xwNOwNPkuDEDFUXZFK8qLh/cKIasPkmWZpG"}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.3.0.tgz_1504812739437_0.6328772504348308"}},"0.3.1":{"name":"poolq","version":"0.3.1","author":{"name":"Steven Berry"},"license":"MIT","main":"main","dependencies":{"deferred-ap":"^0.1.0","js-priority-queue":"^0.1.5"},"devDependencies":{"chai":"^4.1.2","chai-as-promised":"^7.1.1","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^4.0.0","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-rename":"^1.2.2","gulp-tar":"^2.0.0","run-sequence":"^2.2.0","sinon":"^4.0.0","sinon-chai":"^2.13.0"},"gitHead":"b3c5e81c5792ecf8f4a72f24882b2463b1a56390","_id":"poolq@0.3.1","_npmVersion":"5.4.2","_nodeVersion":"8.3.0","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"integrity":"sha512-F/oieFK7TLGTPjrOClPCEKGs5dFfQd/Mw1TFbkYUcXuX9ofWG3wCCdw6/8Crg5H0M/9pSoPclMMjOt5Pq+pQAA==","shasum":"16071664b6fac9fd5567a411a010213f9d0ceec9","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.3.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFF8RxQfO/vOX5okAV/XlkHTAD/k7Mzwep8Cp6RTl5MEAiAUEuBCl/hZnomyVFYoZeaHaIDLrg41TR0ox8W1IjEzDg=="}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.3.1.tgz_1507165453497_0.11117773526348174"}},"0.3.2":{"name":"poolq","version":"0.3.2","author":{"name":"Steven Berry"},"license":"MIT","main":"main","dependencies":{"deferred-ap":"^0.1.0","js-priority-queue":"^0.1.5"},"devDependencies":{"chai":"^4.1.2","chai-as-promised":"^7.1.1","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^4.0.0","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-rename":"^1.2.2","gulp-tar":"^2.0.0","run-sequence":"^2.2.0","sinon":"^4.0.0","sinon-chai":"^2.13.0"},"gitHead":"7f1a6b4a2a2b2311ad3f9bc674a6c2fdbe6d7fd5","description":"**poolq** was motivated by the need for simple, granular flow control over queues of work. **poolq** provides methods to gracefully control process management and shape resource consumption while offering additional sources of informative metrics. The pri","_id":"poolq@0.3.2","_npmVersion":"5.4.2","_nodeVersion":"8.3.0","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"integrity":"sha512-GDEz89K8Nh65C4lJgVYWdRbvr5sfQ2OqeLkLlSZntSS7ywwd0NutbLPOSFus+0N8cKKQahr6wPRITUO/PJPG8A==","shasum":"213205723a40bd133c2bd0f10abf0fce49d53610","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.3.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFKH4RDGpfDVcm9emW84lR4GZiUhrGqt2ydLl155kzW+AiBiJztqdnMc1zYmNEE8RtlSsqP7Q3kREQioIq4cUxVdBw=="}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.3.2.tgz_1507325114416_0.04828271362930536"}},"0.4.0":{"name":"poolq","version":"0.4.0","description":"Basic task flow control for NodeJS.","keywords":["pool","queue","tasks","rate limit","rate limiting","concurrency","concurrency control"],"author":{"name":"Steven Berry"},"repository":{"type":"git","url":"git+https://github.com/sjberry/poolq.git"},"license":"MIT","main":"main","dependencies":{"deferred-ap":"^0.1.0","js-priority-queue":"^0.1.5"},"devDependencies":{"chai":"^4.1.2","chai-as-promised":"^7.1.1","gulp":"^3.9.1","gulp-clean":"^0.3.2","gulp-eslint":"^4.0.0","gulp-gzip":"^1.4.0","gulp-jsonlint":"^1.2.0","gulp-mocha":"^4.3.1","gulp-rename":"^1.2.2","gulp-tar":"^2.0.0","run-sequence":"^2.2.0","sinon":"^4.0.0","sinon-chai":"^2.13.0"},"gitHead":"4b1c1bf0777b496c31a778d979ec3ad1c640e61a","bugs":{"url":"https://github.com/sjberry/poolq/issues"},"homepage":"https://github.com/sjberry/poolq#readme","_id":"poolq@0.4.0","_npmVersion":"5.4.2","_nodeVersion":"8.3.0","_npmUser":{"name":"sjberry","email":"steven@sberry.me"},"dist":{"integrity":"sha512-gE5uy+LkZ5nGJD0zis6q6gI/jvF1HVIMIg8PXhQRDTnfFxpMJ9ZZ3cQklAsOM55TPACaU/YYHPHEuN7zk3xFLQ==","shasum":"9a9ea50f4145436e9bb23a429835e68c0f49487d","tarball":"https://registry.npmjs.org/poolq/-/poolq-0.4.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7issg71SCZR8AXEKp7ahL5rsInSa1qTOHcgmpmCu73QIgXgrZiIGj/VAwVTMl2r5Fg23qm+lppcHexdBZAzqMZjg="}]},"maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/poolq-0.4.0.tgz_1509057064213_0.5845763040706515"}}},"readme":"# poolq\n\n**poolq** was motivated by the need for simple, granular flow control over queues of work.\n**poolq** provides methods to gracefully control process management and shape resource consumption while offering additional sources of informative metrics.\nThe primary design goal is a slim and maintainable codebase to provide a potential basis for more complex application middleware.\n\nIt is important to note that **poolq** `Pool` instances are deliberately limited in scope to in-process memory.\nIf you should need task pooling across processes (e.g. clusters, forks, or IPC) then you will need to make use of a data store such as Redis.\nCross-process pooling is not currently in the feature road map.\n \n## Installation\n\nInstallation is typical and straightforward with some caveats.\n\n```\nnpm install poolq\n```\n\nYou will need a version of NodeJS that supports the `WeakMap` data structure inherently.\n**poolq** leverages weak maps internally and makes no effort to shim for backwards compatibility.\n\nThe test cases are partially written in ES2017 with async/await syntax.\nThe library itself is written in ES6 and does not transpile before publishing.\n\n\n## Usage\n\n**poolq** operates around the concept of `Pool` instances issuing `Slot` instance work slots via acquisition requests.\nConcurrency is controlled by way of stipulating a maximum number of parallel work slots. Slots will be issued up to, but not exceeding this maximum.\nWhen a work slot's task has been completed the `Slot` instance itself **must** be returned to the origin `Pool` to permit subsequent acquisitions.\n\n```js\n'use strict';\n\nconst Pool = require('poolq');\n\n\n// Create a new `Pool` instance.\nlet pool = new Pool();\n\n// Acquire a new work slot, process whatever work needs to happen and return the slot to the pool.\npool.acquire()\n    .then(function(slot) {\n    \t// ...\n    \t\n    \tpool.release(slot);\n    });\n```\n\nBy default a `Pool` instance will have an unbounded maximum number of concurrent work slots.\nThis can be limited with the `max` option on instantiation or subsequently dynamically updated.\n\n```js\nlet pool = new Pool({\n    max: 5\n});\n```\n\n### Instance Methods\n\n>`.acquire()`\n\nAsynchronously obtains a new work slot from the pool.\nThe resulting `Promise` is resolved when the requested work slot is issued by the pool or rejected when an error is encountered.\n\n**Arguments:** `(none)`\n\n**Returns:** `Promise` A promise resolved with the work slot instance when it is successfully issued.\n\n**Example:**\n\n```js\nlet pool = new Pool();\n\npool.acquire()\n    .then(function(slot) {\n    \t// ...\n    })\n    .catch(function(err) {\n    \t// ...\n    });\n```\n\n>`.drain()`\n\nMarks the pool for draining.\nOutstanding work slots that have been issued will not be automatically reclaimed, but additional requests for work slots via `.acquire()` will be rejected.\nThe resulting `Promise` is resolved when the pool has completely drained (i.e. `pool.count === 0`).\nWhile the pool is still draining, subsequent calls to `.drain()` will return the same `Promise` instance.\n\n**Arguments:** `(none)`\n\n**Returns:** `Promise` A promise resolved with no arguments when the pool is completely drained.\n\n**Example:**\n\n```js\nlet pool = new Pool();\n\npool.acquire()\n    .then(function(slot) {\n    \tsetTimeout(function() {\n    \t\tpool.release(slot);\n    \t}, 1500);\n    });\n\npool.drain()\n    .then(function() {\n    \tconsole.log('drained');\n    });\n```\n\n>`.release(slot)`\n\nReleases an acquired work slot back to the pool.\nThis should always be required to maintain a minimal memory footprint.\nIf a concurrency cap is set with `max` this is also required to process subsequent requests for work slots.\nThe `slot` argument **must** have originated from the `Pool` instance or the returned `Promise` will be rejected.\n\n**Arguments:**\n\n`slot` _Slot_ The acquired work slot instance previously obtained from the `Pool`.\n\n**Returns:** `Promise` A promise resolved with no arguments when the work slot is successfully released.\n\n**Example:**\n\n```js\nlet pool = new Pool();\n\npool.acquire()\n    .then(function(slot) {\n    \tpool.release(slot);\n    });\n```\n\n>`.resume()`\n\nResumes a pool enabling or re-enabling work slot acquisition.\nIf the pool is currently draining the existing drain transition will be rejected and work slot issuance will immediately resume.\n\n**Arguments:** `(none)`\n\n**Returns:** `Promise` A promise resolved with no arguments when the pool is successfully resumed.\n\n**Example:**\n\n```js\nlet pool = new Pool();\n\npool.drain()\n    .then(function() {\n    \t// ...\n    \t\n    \tpool.resume();\n    });\n```\n\n### Properties\n\n>**count** _Number_ _readonly_ The current number of issued work slots.\n\nA work slot is requested with `.acquire()` but is not issued until the `Pool` instance has suitable space available.\nThe `count` property indicates how many slots are currently issued but not yet returned.\n\n>**draining** _Boolean_ _readonly_ A flag indicating whether or not the pool is currently draining.\n\nA `Pool` instance can be drained with the `.drain()` method.\nDoing so will prevent additional work slots from being issued.\nThis property indicates whether the `Pool` instance is currently draining.\n\n>**max** _Number_ The maximum number of concurrent active work slots.\n\nWhile the number of _pending_ work slots is ostensibly unbounded, there is an established limit on maximum number of concurrent slots that will be resolved via `.acquire()`.\nThe `max` property can be set dynamically on an active `Pool` instance and work slots will be issued as appropriate.\nReducing the `max` below the current `count` will not affect the slots already issued but will prevent additional slots from being issued until enough slots have been returned such that `count < max`.\n\n>**state** _String_ _readonly_ The current state of the pool.\n\nA `Pool` instance can have a few different states depending on whether or not it has been drained, resumed, etc.\nThe possible states are accessible as enumerated constants in `Pool.states`.\n\n>**waiting** _Number_ _readonly_ The current number of pending, requested work slots.\n\nWhen the number of requested work slots exceeds the concurrency stipulated by the `max` property they are relegated to a queue.\nThe `waiting` property indicates the number of queued work slot acquisition requests.\n\n\n## Examples\n\nThere are some rudimentary examples composed in the `examples/` sub-folder for reference.\n","maintainers":[{"name":"sjberry","email":"steven@sberry.me"}],"time":{"modified":"2022-06-24T08:13:21.362Z","created":"2017-06-06T12:19:58.110Z","0.2.0":"2017-06-06T12:19:58.110Z","0.1.0":"2017-06-06T12:20:21.270Z","0.3.0":"2017-09-07T19:32:21.188Z","0.3.1":"2017-10-05T01:04:14.568Z","0.3.2":"2017-10-06T21:25:15.381Z","0.4.0":"2017-10-26T22:31:05.138Z"},"author":{"name":"Steven Berry"},"license":"MIT","readmeFilename":"README.md","description":"Basic task flow control for NodeJS.","homepage":"https://github.com/sjberry/poolq#readme","keywords":["pool","queue","tasks","rate limit","rate limiting","concurrency","concurrency control"],"repository":{"type":"git","url":"git+https://github.com/sjberry/poolq.git"},"bugs":{"url":"https://github.com/sjberry/poolq/issues"}}