apify 2.3.1-beta.4 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/package.json +69 -128
- package/build/actor.d.ts +0 -113
- package/build/actor.d.ts.map +0 -1
- package/build/actor.js +0 -582
- package/build/actor.js.map +0 -1
- package/build/apify.d.ts +0 -752
- package/build/apify.d.ts.map +0 -1
- package/build/apify.js +0 -877
- package/build/apify.js.map +0 -1
- package/build/autoscaling/autoscaled_pool.d.ts +0 -384
- package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/build/autoscaling/autoscaled_pool.js +0 -557
- package/build/autoscaling/autoscaled_pool.js.map +0 -1
- package/build/autoscaling/snapshotter.d.ts +0 -278
- package/build/autoscaling/snapshotter.d.ts.map +0 -1
- package/build/autoscaling/snapshotter.js +0 -447
- package/build/autoscaling/snapshotter.js.map +0 -1
- package/build/autoscaling/system_status.d.ts +0 -224
- package/build/autoscaling/system_status.d.ts.map +0 -1
- package/build/autoscaling/system_status.js +0 -228
- package/build/autoscaling/system_status.js.map +0 -1
- package/build/browser_launchers/browser_launcher.d.ts +0 -154
- package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
- package/build/browser_launchers/browser_launcher.js +0 -160
- package/build/browser_launchers/browser_launcher.js.map +0 -1
- package/build/browser_launchers/browser_plugin.d.ts +0 -23
- package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
- package/build/browser_launchers/browser_plugin.js +0 -25
- package/build/browser_launchers/browser_plugin.js.map +0 -1
- package/build/browser_launchers/playwright_launcher.d.ts +0 -131
- package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
- package/build/browser_launchers/playwright_launcher.js +0 -150
- package/build/browser_launchers/playwright_launcher.js.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
- package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.js +0 -197
- package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
- package/build/cache_container.d.ts +0 -31
- package/build/cache_container.d.ts.map +0 -1
- package/build/cache_container.js +0 -48
- package/build/cache_container.js.map +0 -1
- package/build/configuration.d.ts +0 -226
- package/build/configuration.d.ts.map +0 -1
- package/build/configuration.js +0 -325
- package/build/configuration.js.map +0 -1
- package/build/constants.d.ts +0 -37
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -41
- package/build/constants.js.map +0 -1
- package/build/crawlers/basic_crawler.d.ts +0 -443
- package/build/crawlers/basic_crawler.d.ts.map +0 -1
- package/build/crawlers/basic_crawler.js +0 -664
- package/build/crawlers/basic_crawler.js.map +0 -1
- package/build/crawlers/browser_crawler.d.ts +0 -512
- package/build/crawlers/browser_crawler.d.ts.map +0 -1
- package/build/crawlers/browser_crawler.js +0 -540
- package/build/crawlers/browser_crawler.js.map +0 -1
- package/build/crawlers/cheerio_crawler.d.ts +0 -931
- package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
- package/build/crawlers/cheerio_crawler.js +0 -913
- package/build/crawlers/cheerio_crawler.js.map +0 -1
- package/build/crawlers/crawler_extension.d.ts +0 -10
- package/build/crawlers/crawler_extension.d.ts.map +0 -1
- package/build/crawlers/crawler_extension.js +0 -19
- package/build/crawlers/crawler_extension.js.map +0 -1
- package/build/crawlers/crawler_utils.d.ts +0 -34
- package/build/crawlers/crawler_utils.d.ts.map +0 -1
- package/build/crawlers/crawler_utils.js +0 -87
- package/build/crawlers/crawler_utils.js.map +0 -1
- package/build/crawlers/playwright_crawler.d.ts +0 -448
- package/build/crawlers/playwright_crawler.d.ts.map +0 -1
- package/build/crawlers/playwright_crawler.js +0 -299
- package/build/crawlers/playwright_crawler.js.map +0 -1
- package/build/crawlers/puppeteer_crawler.d.ts +0 -425
- package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
- package/build/crawlers/puppeteer_crawler.js +0 -299
- package/build/crawlers/puppeteer_crawler.js.map +0 -1
- package/build/crawlers/statistics.d.ts +0 -185
- package/build/crawlers/statistics.d.ts.map +0 -1
- package/build/crawlers/statistics.js +0 -331
- package/build/crawlers/statistics.js.map +0 -1
- package/build/enqueue_links/click_elements.d.ts +0 -179
- package/build/enqueue_links/click_elements.d.ts.map +0 -1
- package/build/enqueue_links/click_elements.js +0 -434
- package/build/enqueue_links/click_elements.js.map +0 -1
- package/build/enqueue_links/enqueue_links.d.ts +0 -117
- package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/build/enqueue_links/enqueue_links.js +0 -163
- package/build/enqueue_links/enqueue_links.js.map +0 -1
- package/build/enqueue_links/shared.d.ts +0 -42
- package/build/enqueue_links/shared.d.ts.map +0 -1
- package/build/enqueue_links/shared.js +0 -121
- package/build/enqueue_links/shared.js.map +0 -1
- package/build/errors.d.ts +0 -29
- package/build/errors.d.ts.map +0 -1
- package/build/errors.js +0 -38
- package/build/errors.js.map +0 -1
- package/build/events.d.ts +0 -11
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -147
- package/build/events.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/main.d.ts +0 -179
- package/build/main.d.ts.map +0 -1
- package/build/main.js +0 -81
- package/build/main.js.map +0 -1
- package/build/playwright_utils.d.ts +0 -9
- package/build/playwright_utils.d.ts.map +0 -1
- package/build/playwright_utils.js +0 -90
- package/build/playwright_utils.js.map +0 -1
- package/build/proxy_configuration.d.ts +0 -411
- package/build/proxy_configuration.d.ts.map +0 -1
- package/build/proxy_configuration.js +0 -517
- package/build/proxy_configuration.js.map +0 -1
- package/build/pseudo_url.d.ts +0 -86
- package/build/pseudo_url.d.ts.map +0 -1
- package/build/pseudo_url.js +0 -153
- package/build/pseudo_url.js.map +0 -1
- package/build/puppeteer_request_interception.d.ts +0 -8
- package/build/puppeteer_request_interception.d.ts.map +0 -1
- package/build/puppeteer_request_interception.js +0 -235
- package/build/puppeteer_request_interception.js.map +0 -1
- package/build/puppeteer_utils.d.ts +0 -250
- package/build/puppeteer_utils.d.ts.map +0 -1
- package/build/puppeteer_utils.js +0 -551
- package/build/puppeteer_utils.js.map +0 -1
- package/build/request.d.ts +0 -180
- package/build/request.d.ts.map +0 -1
- package/build/request.js +0 -261
- package/build/request.js.map +0 -1
- package/build/request_list.d.ts +0 -581
- package/build/request_list.d.ts.map +0 -1
- package/build/request_list.js +0 -826
- package/build/request_list.js.map +0 -1
- package/build/serialization.d.ts +0 -5
- package/build/serialization.d.ts.map +0 -1
- package/build/serialization.js +0 -139
- package/build/serialization.js.map +0 -1
- package/build/session_pool/errors.d.ts +0 -11
- package/build/session_pool/errors.d.ts.map +0 -1
- package/build/session_pool/errors.js +0 -18
- package/build/session_pool/errors.js.map +0 -1
- package/build/session_pool/events.d.ts +0 -5
- package/build/session_pool/events.d.ts.map +0 -1
- package/build/session_pool/events.js +0 -6
- package/build/session_pool/events.js.map +0 -1
- package/build/session_pool/session.d.ts +0 -286
- package/build/session_pool/session.d.ts.map +0 -1
- package/build/session_pool/session.js +0 -355
- package/build/session_pool/session.js.map +0 -1
- package/build/session_pool/session_pool.d.ts +0 -280
- package/build/session_pool/session_pool.d.ts.map +0 -1
- package/build/session_pool/session_pool.js +0 -393
- package/build/session_pool/session_pool.js.map +0 -1
- package/build/session_pool/session_utils.d.ts +0 -4
- package/build/session_pool/session_utils.d.ts.map +0 -1
- package/build/session_pool/session_utils.js +0 -24
- package/build/session_pool/session_utils.js.map +0 -1
- package/build/stealth/hiding_tricks.d.ts +0 -22
- package/build/stealth/hiding_tricks.d.ts.map +0 -1
- package/build/stealth/hiding_tricks.js +0 -308
- package/build/stealth/hiding_tricks.js.map +0 -1
- package/build/stealth/stealth.d.ts +0 -56
- package/build/stealth/stealth.d.ts.map +0 -1
- package/build/stealth/stealth.js +0 -125
- package/build/stealth/stealth.js.map +0 -1
- package/build/storages/dataset.d.ts +0 -288
- package/build/storages/dataset.d.ts.map +0 -1
- package/build/storages/dataset.js +0 -480
- package/build/storages/dataset.js.map +0 -1
- package/build/storages/key_value_store.d.ts +0 -243
- package/build/storages/key_value_store.d.ts.map +0 -1
- package/build/storages/key_value_store.js +0 -462
- package/build/storages/key_value_store.js.map +0 -1
- package/build/storages/request_queue.d.ts +0 -318
- package/build/storages/request_queue.d.ts.map +0 -1
- package/build/storages/request_queue.js +0 -636
- package/build/storages/request_queue.js.map +0 -1
- package/build/storages/storage_manager.d.ts +0 -87
- package/build/storages/storage_manager.d.ts.map +0 -1
- package/build/storages/storage_manager.js +0 -150
- package/build/storages/storage_manager.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build/typedefs.d.ts +0 -146
- package/build/typedefs.d.ts.map +0 -1
- package/build/typedefs.js +0 -88
- package/build/typedefs.js.map +0 -1
- package/build/utils.d.ts +0 -175
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -731
- package/build/utils.js.map +0 -1
- package/build/utils_log.d.ts +0 -41
- package/build/utils_log.d.ts.map +0 -1
- package/build/utils_log.js +0 -192
- package/build/utils_log.js.map +0 -1
- package/build/utils_request.d.ts +0 -77
- package/build/utils_request.d.ts.map +0 -1
- package/build/utils_request.js +0 -385
- package/build/utils_request.js.map +0 -1
- package/build/utils_social.d.ts +0 -210
- package/build/utils_social.d.ts.map +0 -1
- package/build/utils_social.js +0 -787
- package/build/utils_social.js.map +0 -1
- package/build/validators.d.ts +0 -23
- package/build/validators.d.ts.map +0 -1
- package/build/validators.js +0 -29
- package/build/validators.js.map +0 -1
|
@@ -1,557 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const timeout_1 = require("@apify/timeout");
|
|
5
|
-
const utilities_1 = require("@apify/utilities");
|
|
6
|
-
const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
|
|
7
|
-
const snapshotter_1 = (0, tslib_1.__importDefault)(require("./snapshotter")); // eslint-disable-line import/named,no-unused-vars
|
|
8
|
-
const system_status_1 = (0, tslib_1.__importDefault)(require("./system_status")); // eslint-disable-line import/named,no-unused-vars
|
|
9
|
-
const utils_log_1 = (0, tslib_1.__importDefault)(require("../utils_log")); // eslint-disable-line no-unused-vars
|
|
10
|
-
/**
|
|
11
|
-
* @typedef AutoscaledPoolOptions
|
|
12
|
-
* @property {Function} [runTaskFunction]
|
|
13
|
-
* A function that performs an asynchronous resource-intensive task.
|
|
14
|
-
* The function must either be labeled `async` or return a promise.
|
|
15
|
-
*
|
|
16
|
-
* @property {Function} [isTaskReadyFunction]
|
|
17
|
-
* A function that indicates whether `runTaskFunction` should be called.
|
|
18
|
-
* This function is called every time there is free capacity for a new task and it should
|
|
19
|
-
* indicate whether it should start a new task or not by resolving to either `true` or `false`.
|
|
20
|
-
* Besides its obvious use, it is also useful for task throttling to save resources.
|
|
21
|
-
*
|
|
22
|
-
* @property {Function} [isFinishedFunction]
|
|
23
|
-
* A function that is called only when there are no tasks to be processed.
|
|
24
|
-
* If it resolves to `true` then the pool's run finishes. Being called only
|
|
25
|
-
* when there are no tasks being processed means that as long as `isTaskReadyFunction()`
|
|
26
|
-
* keeps resolving to `true`, `isFinishedFunction()` will never be called.
|
|
27
|
-
* To abort a run, use the {@link AutoscaledPool#abort} method.
|
|
28
|
-
*
|
|
29
|
-
* @property {number} [minConcurrency=1]
|
|
30
|
-
* The minimum number of tasks running in parallel.
|
|
31
|
-
*
|
|
32
|
-
* *WARNING:* If you set this value too high with respect to the available system memory and CPU, your code might run extremely slow or crash.
|
|
33
|
-
* If you're not sure, just keep the default value and the concurrency will scale up automatically.
|
|
34
|
-
* @property {number} [maxConcurrency=1000]
|
|
35
|
-
* The maximum number of tasks running in parallel.
|
|
36
|
-
* @property {number} [desiredConcurrency]
|
|
37
|
-
* The desired number of tasks that should be running parallel on the start of the pool,
|
|
38
|
-
* if there is a large enough supply of them.
|
|
39
|
-
* By default, it is `minConcurrency`.
|
|
40
|
-
* @property {number} [desiredConcurrencyRatio=0.95]
|
|
41
|
-
* Minimum level of desired concurrency to reach before more scaling up is allowed.
|
|
42
|
-
* @property {number} [scaleUpStepRatio=0.05]
|
|
43
|
-
* Defines the fractional amount of desired concurrency to be added with each scaling up.
|
|
44
|
-
* The minimum scaling step is one.
|
|
45
|
-
* @property {number} [scaleDownStepRatio=0.05]
|
|
46
|
-
* Defines the amount of desired concurrency to be subtracted with each scaling down.
|
|
47
|
-
* The minimum scaling step is one.
|
|
48
|
-
* @property {number} [maybeRunIntervalSecs=0.5]
|
|
49
|
-
* Indicates how often the pool should call the `runTaskFunction()` to start a new task, in seconds.
|
|
50
|
-
* This has no effect on starting new tasks immediately after a task completes.
|
|
51
|
-
* @property {number} [loggingIntervalSecs=60]
|
|
52
|
-
* Specifies a period in which the instance logs its state, in seconds.
|
|
53
|
-
* Set to `null` to disable periodic logging.
|
|
54
|
-
* @property {number} [autoscaleIntervalSecs=10]
|
|
55
|
-
* Defines in seconds how often the pool should attempt to adjust the desired concurrency
|
|
56
|
-
* based on the latest system status. Setting it lower than 1 might have a severe impact on performance.
|
|
57
|
-
* We suggest using a value from 5 to 20.
|
|
58
|
-
* @property {number} [taskTimeoutSecs=0]
|
|
59
|
-
* Timeout in which the `runTaskFunction` needs to finish, given in seconds.
|
|
60
|
-
* @property {SnapshotterOptions} [snapshotterOptions]
|
|
61
|
-
* Options to be passed down to the {@link Snapshotter} constructor. This is useful for fine-tuning
|
|
62
|
-
* the snapshot intervals and history.
|
|
63
|
-
* @property {SystemStatusOptions} [systemStatusOptions]
|
|
64
|
-
* Options to be passed down to the {@link SystemStatus} constructor. This is useful for fine-tuning
|
|
65
|
-
* the system status reports. If a custom snapshotter is set in the options, it will be used
|
|
66
|
-
* by the pool.
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Manages a pool of asynchronous resource-intensive tasks that are executed in parallel.
|
|
70
|
-
* The pool only starts new tasks if there is enough free CPU and memory available
|
|
71
|
-
* and the Javascript event loop is not blocked.
|
|
72
|
-
*
|
|
73
|
-
* The information about the CPU and memory usage is obtained by the {@link Snapshotter} class,
|
|
74
|
-
* which makes regular snapshots of system resources that may be either local
|
|
75
|
-
* or from the Apify cloud infrastructure in case the process is running on the Apify platform.
|
|
76
|
-
* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the {@link SystemStatus} class.
|
|
77
|
-
*
|
|
78
|
-
* Before running the pool, you need to implement the following three functions:
|
|
79
|
-
* {@link AutoscaledPoolOptions#runTaskFunction},
|
|
80
|
-
* {@link AutoscaledPoolOptions#isTaskReadyFunction} and
|
|
81
|
-
* {@link AutoscaledPoolOptions#isFinishedFunction}.
|
|
82
|
-
*
|
|
83
|
-
* The auto-scaled pool is started by calling the {@link AutoscaledPool#run} function.
|
|
84
|
-
* The pool periodically queries the {@link AutoscaledPoolOptions#isTaskReadyFunction} function
|
|
85
|
-
* for more tasks, managing optimal concurrency, until the function resolves to `false`. The pool then queries
|
|
86
|
-
* the {@link AutoscaledPoolOptions#isFinishedFunction}. If it resolves to `true`, the run finishes after all running tasks complete.
|
|
87
|
-
* If it resolves to `false`, it assumes there will be more tasks available later and keeps periodically querying for tasks.
|
|
88
|
-
* If any of the tasks throws then the {@link AutoscaledPool#run} function rejects the promise with an error.
|
|
89
|
-
*
|
|
90
|
-
* The pool evaluates whether it should start a new task every time one of the tasks finishes
|
|
91
|
-
* and also in the interval set by the `options.maybeRunIntervalSecs` parameter.
|
|
92
|
-
*
|
|
93
|
-
* **Example usage:**
|
|
94
|
-
*
|
|
95
|
-
* ```javascript
|
|
96
|
-
* const pool = new Apify.AutoscaledPool({
|
|
97
|
-
* maxConcurrency: 50,
|
|
98
|
-
* runTaskFunction: async () => {
|
|
99
|
-
* // Run some resource-intensive asynchronous operation here.
|
|
100
|
-
* },
|
|
101
|
-
* isTaskReadyFunction: async () => {
|
|
102
|
-
* // Tell the pool whether more tasks are ready to be processed.
|
|
103
|
-
* // Return true or false
|
|
104
|
-
* },
|
|
105
|
-
* isFinishedFunction: async () => {
|
|
106
|
-
* // Tell the pool whether it should finish
|
|
107
|
-
* // or wait for more tasks to become available.
|
|
108
|
-
* // Return true or false
|
|
109
|
-
* }
|
|
110
|
-
* });
|
|
111
|
-
*
|
|
112
|
-
* await pool.run();
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
class AutoscaledPool {
|
|
116
|
-
/**
|
|
117
|
-
* @param {AutoscaledPoolOptions} options
|
|
118
|
-
* All `AutoscaledPool` configuration options.
|
|
119
|
-
*/
|
|
120
|
-
constructor(options) {
|
|
121
|
-
(0, ow_1.default)(options, ow_1.default.object.exactShape({
|
|
122
|
-
runTaskFunction: ow_1.default.function,
|
|
123
|
-
isFinishedFunction: ow_1.default.function,
|
|
124
|
-
isTaskReadyFunction: ow_1.default.function,
|
|
125
|
-
maxConcurrency: ow_1.default.optional.number,
|
|
126
|
-
minConcurrency: ow_1.default.optional.number,
|
|
127
|
-
desiredConcurrency: ow_1.default.optional.number,
|
|
128
|
-
desiredConcurrencyRatio: ow_1.default.optional.number,
|
|
129
|
-
scaleUpStepRatio: ow_1.default.optional.number,
|
|
130
|
-
scaleDownStepRatio: ow_1.default.optional.number,
|
|
131
|
-
maybeRunIntervalSecs: ow_1.default.optional.number,
|
|
132
|
-
loggingIntervalSecs: ow_1.default.any(ow_1.default.number, ow_1.default.nullOrUndefined),
|
|
133
|
-
autoscaleIntervalSecs: ow_1.default.optional.number,
|
|
134
|
-
taskTimeoutSecs: ow_1.default.optional.number,
|
|
135
|
-
systemStatusOptions: ow_1.default.optional.object,
|
|
136
|
-
snapshotterOptions: ow_1.default.optional.object,
|
|
137
|
-
log: ow_1.default.optional.object,
|
|
138
|
-
}));
|
|
139
|
-
const { runTaskFunction, isFinishedFunction, isTaskReadyFunction, maxConcurrency = 1000, minConcurrency = 1, desiredConcurrency, desiredConcurrencyRatio = 0.90, scaleUpStepRatio = 0.05, scaleDownStepRatio = 0.05, maybeRunIntervalSecs = 0.5, loggingIntervalSecs = 60, taskTimeoutSecs = 0, autoscaleIntervalSecs = 10, systemStatusOptions, snapshotterOptions, log = utils_log_1.default, } = options;
|
|
140
|
-
/**
|
|
141
|
-
* @type {Log}
|
|
142
|
-
*/
|
|
143
|
-
this.log = log.child({ prefix: 'AutoscaledPool' });
|
|
144
|
-
// Configurable properties.
|
|
145
|
-
this.desiredConcurrencyRatio = desiredConcurrencyRatio;
|
|
146
|
-
this.scaleUpStepRatio = scaleUpStepRatio;
|
|
147
|
-
this.scaleDownStepRatio = scaleDownStepRatio;
|
|
148
|
-
this.maybeRunIntervalMillis = maybeRunIntervalSecs * 1000;
|
|
149
|
-
this.loggingIntervalMillis = loggingIntervalSecs * 1000;
|
|
150
|
-
this.autoscaleIntervalMillis = autoscaleIntervalSecs * 1000;
|
|
151
|
-
this.taskTimeoutMillis = taskTimeoutSecs * 1000;
|
|
152
|
-
this.runTaskFunction = runTaskFunction;
|
|
153
|
-
this.isFinishedFunction = isFinishedFunction;
|
|
154
|
-
this.isTaskReadyFunction = isTaskReadyFunction;
|
|
155
|
-
// Internal properties.
|
|
156
|
-
this._minConcurrency = minConcurrency;
|
|
157
|
-
this._maxConcurrency = maxConcurrency;
|
|
158
|
-
this._desiredConcurrency = typeof desiredConcurrency === 'number' ? desiredConcurrency : minConcurrency;
|
|
159
|
-
this._currentConcurrency = 0;
|
|
160
|
-
this.isStopped = false;
|
|
161
|
-
this.lastLoggingTime = 0;
|
|
162
|
-
this.resolve = null;
|
|
163
|
-
this.reject = null;
|
|
164
|
-
this._autoscale = this._autoscale.bind(this);
|
|
165
|
-
this._maybeRunTask = this._maybeRunTask.bind(this);
|
|
166
|
-
// Create instances with correct options.
|
|
167
|
-
const ssoCopy = { ...systemStatusOptions };
|
|
168
|
-
if (!ssoCopy.snapshotter)
|
|
169
|
-
ssoCopy.snapshotter = new snapshotter_1.default({ ...snapshotterOptions, log: this.log });
|
|
170
|
-
this.snapshotter = ssoCopy.snapshotter;
|
|
171
|
-
this.systemStatus = new system_status_1.default(ssoCopy);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Gets the minimum number of tasks running in parallel.
|
|
175
|
-
*
|
|
176
|
-
* @return {number}
|
|
177
|
-
*/
|
|
178
|
-
get minConcurrency() {
|
|
179
|
-
return this._minConcurrency;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Sets the minimum number of tasks running in parallel.
|
|
183
|
-
*
|
|
184
|
-
* *WARNING:* If you set this value too high with respect to the available system memory and CPU, your code might run extremely slow or crash.
|
|
185
|
-
* If you're not sure, just keep the default value and the concurrency will scale up automatically.
|
|
186
|
-
*
|
|
187
|
-
* @param {number} value
|
|
188
|
-
*/
|
|
189
|
-
set minConcurrency(value) {
|
|
190
|
-
(0, ow_1.default)(value, ow_1.default.number);
|
|
191
|
-
this._minConcurrency = value;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Gets the maximum number of tasks running in parallel.
|
|
195
|
-
*
|
|
196
|
-
* @return {number}
|
|
197
|
-
*/
|
|
198
|
-
get maxConcurrency() {
|
|
199
|
-
return this._maxConcurrency;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Sets the maximum number of tasks running in parallel.
|
|
203
|
-
*
|
|
204
|
-
* @param {number} value
|
|
205
|
-
*/
|
|
206
|
-
set maxConcurrency(value) {
|
|
207
|
-
(0, ow_1.default)(value, ow_1.default.number);
|
|
208
|
-
this._maxConcurrency = value;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Gets the desired concurrency for the pool,
|
|
212
|
-
* which is an estimated number of parallel tasks that the system can currently support.
|
|
213
|
-
*
|
|
214
|
-
* @return {number}
|
|
215
|
-
*/
|
|
216
|
-
get desiredConcurrency() {
|
|
217
|
-
return this._desiredConcurrency;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Sets the desired concurrency for the pool, i.e. the number of tasks that should be running
|
|
221
|
-
* in parallel if there's large enough supply of tasks.
|
|
222
|
-
*
|
|
223
|
-
* @param {number} value
|
|
224
|
-
*/
|
|
225
|
-
set desiredConcurrency(value) {
|
|
226
|
-
(0, ow_1.default)(value, ow_1.default.number);
|
|
227
|
-
this._desiredConcurrency = value;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Gets the the number of parallel tasks currently running in the pool.
|
|
231
|
-
*
|
|
232
|
-
* @return {number}
|
|
233
|
-
*/
|
|
234
|
-
get currentConcurrency() {
|
|
235
|
-
return this._currentConcurrency;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Runs the auto-scaled pool. Returns a promise that gets resolved or rejected once
|
|
239
|
-
* all the tasks are finished or one of them fails.
|
|
240
|
-
*
|
|
241
|
-
* @return {Promise<void>}
|
|
242
|
-
*/
|
|
243
|
-
async run() {
|
|
244
|
-
this.poolPromise = new Promise((resolve, reject) => {
|
|
245
|
-
this.resolve = resolve;
|
|
246
|
-
this.reject = reject;
|
|
247
|
-
});
|
|
248
|
-
await this.snapshotter.start();
|
|
249
|
-
// This interval checks the system status and updates the desired concurrency accordingly.
|
|
250
|
-
this.autoscaleInterval = (0, utilities_1.betterSetInterval)(this._autoscale, this.autoscaleIntervalMillis);
|
|
251
|
-
// This is here because if we scale down to let's say 1, then after each promise is finished
|
|
252
|
-
// this._maybeRunTask() doesn't trigger another one. So if that 1 instance gets stuck it results
|
|
253
|
-
// in the actor getting stuck and even after scaling up it never triggers another promise.
|
|
254
|
-
this.maybeRunInterval = (0, utilities_1.betterSetInterval)(this._maybeRunTask, this.maybeRunIntervalMillis);
|
|
255
|
-
try {
|
|
256
|
-
await this.poolPromise;
|
|
257
|
-
}
|
|
258
|
-
finally {
|
|
259
|
-
// If resolve is null, the pool is already destroyed.
|
|
260
|
-
if (this.resolve)
|
|
261
|
-
await this._destroy();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Aborts the run of the auto-scaled pool and destroys it. The promise returned from
|
|
266
|
-
* the {@link AutoscaledPool#run} function will immediately resolve, no more new tasks
|
|
267
|
-
* will be spawned and all running tasks will be left in their current state.
|
|
268
|
-
*
|
|
269
|
-
* Due to the nature of the tasks, auto-scaled pool cannot reliably guarantee abortion
|
|
270
|
-
* of all the running tasks, therefore, no abortion is attempted and some of the tasks
|
|
271
|
-
* may finish, while others may not. Essentially, auto-scaled pool doesn't care about
|
|
272
|
-
* their state after the invocation of `.abort()`, but that does not mean that some
|
|
273
|
-
* parts of their asynchronous chains of commands will not execute.
|
|
274
|
-
*
|
|
275
|
-
* @return {Promise<void>}
|
|
276
|
-
*/
|
|
277
|
-
async abort() {
|
|
278
|
-
this.isStopped = true;
|
|
279
|
-
if (this.resolve) {
|
|
280
|
-
this.resolve();
|
|
281
|
-
await this._destroy();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Prevents the auto-scaled pool from starting new tasks, but allows the running ones to finish
|
|
286
|
-
* (unlike abort, which terminates them). Used together with {@link AutoscaledPool#resume}
|
|
287
|
-
*
|
|
288
|
-
* The function's promise will resolve once all running tasks have completed and the pool
|
|
289
|
-
* is effectively idle. If the `timeoutSecs` argument is provided, the promise will reject
|
|
290
|
-
* with a timeout error after the `timeoutSecs` seconds.
|
|
291
|
-
*
|
|
292
|
-
* The promise returned from the {@link AutoscaledPool#run} function will not resolve
|
|
293
|
-
* when `.pause()` is invoked (unlike abort, which resolves it).
|
|
294
|
-
*
|
|
295
|
-
* @param {number} [timeoutSecs]
|
|
296
|
-
* @return {Promise<void>}
|
|
297
|
-
*/
|
|
298
|
-
async pause(timeoutSecs) {
|
|
299
|
-
if (this.isStopped)
|
|
300
|
-
return;
|
|
301
|
-
this.isStopped = true;
|
|
302
|
-
return new Promise((resolve, reject) => {
|
|
303
|
-
let timeout;
|
|
304
|
-
if (timeoutSecs) {
|
|
305
|
-
timeout = setTimeout(() => {
|
|
306
|
-
const err = new Error('The pool\'s running tasks did not finish'
|
|
307
|
-
+ `in ${timeoutSecs} secs after pool.pause() invocation.`);
|
|
308
|
-
reject(err);
|
|
309
|
-
}, timeoutSecs);
|
|
310
|
-
}
|
|
311
|
-
const interval = setInterval(() => {
|
|
312
|
-
if (this._currentConcurrency <= 0) {
|
|
313
|
-
// Clean up timeout and interval to prevent process hanging.
|
|
314
|
-
if (timeout)
|
|
315
|
-
clearTimeout(timeout);
|
|
316
|
-
clearInterval(interval);
|
|
317
|
-
resolve();
|
|
318
|
-
}
|
|
319
|
-
}, this.maybeRunIntervalMillis);
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Resumes the operation of the autoscaled-pool by allowing more tasks to be run.
|
|
324
|
-
* Used together with {@link AutoscaledPool#pause}
|
|
325
|
-
*
|
|
326
|
-
* Tasks will automatically start running again in `options.maybeRunIntervalSecs`.
|
|
327
|
-
*/
|
|
328
|
-
resume() {
|
|
329
|
-
this.isStopped = false;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Starts a new task
|
|
333
|
-
* if the number of running tasks (current concurrency) is lower than desired concurrency
|
|
334
|
-
* and the system is not currently overloaded
|
|
335
|
-
* and this.isTaskReadyFunction() returns true.
|
|
336
|
-
*
|
|
337
|
-
* It doesn't allow multiple concurrent runs of this method.
|
|
338
|
-
*
|
|
339
|
-
* @ignore
|
|
340
|
-
* @protected
|
|
341
|
-
* @internal
|
|
342
|
-
*/
|
|
343
|
-
async _maybeRunTask(intervalCallback) {
|
|
344
|
-
this.log.perf('Attempting to run a task.');
|
|
345
|
-
// Check if the function was invoked by the maybeRunInterval and use an empty function if not.
|
|
346
|
-
const done = intervalCallback || (() => { });
|
|
347
|
-
// Prevent starting a new task if:
|
|
348
|
-
// - the pool is paused or aborted
|
|
349
|
-
if (this.isStopped) {
|
|
350
|
-
this.log.perf('Task will not run. AutoscaledPool is stopped.');
|
|
351
|
-
return done();
|
|
352
|
-
}
|
|
353
|
-
// - we are already querying for a task.
|
|
354
|
-
if (this.queryingIsTaskReady) {
|
|
355
|
-
this.log.perf('Task will not run. Waiting for a ready task.');
|
|
356
|
-
return done();
|
|
357
|
-
}
|
|
358
|
-
// - we would exceed desired concurrency.
|
|
359
|
-
if (this._currentConcurrency >= this._desiredConcurrency) {
|
|
360
|
-
this.log.perf('Task will not run. Desired concurrency achieved.');
|
|
361
|
-
return done();
|
|
362
|
-
}
|
|
363
|
-
// - system is overloaded now and we are at or above minConcurrency
|
|
364
|
-
const currentStatus = this.systemStatus.getCurrentStatus();
|
|
365
|
-
const { isSystemIdle } = currentStatus;
|
|
366
|
-
if (!isSystemIdle && this._currentConcurrency >= this._minConcurrency) {
|
|
367
|
-
this.log.perf('Task will not be run. System is overloaded.', currentStatus);
|
|
368
|
-
return done();
|
|
369
|
-
}
|
|
370
|
-
// - a task is ready.
|
|
371
|
-
this.queryingIsTaskReady = true;
|
|
372
|
-
let isTaskReady;
|
|
373
|
-
try {
|
|
374
|
-
this.log.perf('Checking for ready tasks.');
|
|
375
|
-
isTaskReady = await this.isTaskReadyFunction();
|
|
376
|
-
}
|
|
377
|
-
catch (err) {
|
|
378
|
-
this.log.perf('Checking for ready tasks failed.');
|
|
379
|
-
// We might have already rejected this promise.
|
|
380
|
-
if (this.reject) {
|
|
381
|
-
// No need to log all concurrent errors.
|
|
382
|
-
this.log.exception(err, 'isTaskReadyFunction failed');
|
|
383
|
-
this.reject(err);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
finally {
|
|
387
|
-
this.queryingIsTaskReady = false;
|
|
388
|
-
}
|
|
389
|
-
if (!isTaskReady) {
|
|
390
|
-
this.log.perf('Task will not run. No tasks are ready.');
|
|
391
|
-
done();
|
|
392
|
-
// No tasks could mean that we're finished with all tasks.
|
|
393
|
-
return this._maybeFinish();
|
|
394
|
-
}
|
|
395
|
-
try {
|
|
396
|
-
// Everything's fine. Run task.
|
|
397
|
-
this._currentConcurrency++;
|
|
398
|
-
// Try to run next task to build up concurrency,
|
|
399
|
-
// but defer it so it doesn't create a cycle.
|
|
400
|
-
setImmediate(this._maybeRunTask);
|
|
401
|
-
// We need to restart interval here, so that it doesn't get blocked by a stalled task.
|
|
402
|
-
done();
|
|
403
|
-
// Execute the current task.
|
|
404
|
-
this.log.perf('Running a task.');
|
|
405
|
-
if (this.taskTimeoutMillis > 0) {
|
|
406
|
-
await (0, timeout_1.addTimeoutToPromise)(() => this.runTaskFunction(), this.taskTimeoutMillis, `runTaskFunction timed out after ${this.taskTimeoutMillis / 1000} seconds.`);
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
await this.runTaskFunction();
|
|
410
|
-
}
|
|
411
|
-
this.log.perf('Task finished.');
|
|
412
|
-
this._currentConcurrency--;
|
|
413
|
-
// Run task after the previous one finished.
|
|
414
|
-
setImmediate(this._maybeRunTask);
|
|
415
|
-
}
|
|
416
|
-
catch (err) {
|
|
417
|
-
this.log.perf('Running a task failed.');
|
|
418
|
-
// We might have already rejected this promise.
|
|
419
|
-
if (this.reject) {
|
|
420
|
-
// No need to log all concurrent errors.
|
|
421
|
-
this.log.exception(err, 'runTaskFunction failed.');
|
|
422
|
-
this.reject(err);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Gets called every autoScaleIntervalSecs and evaluates the current system status.
|
|
428
|
-
* If the system IS NOT overloaded and the settings allow it, it scales up.
|
|
429
|
-
* If the system IS overloaded and the settings allow it, it scales down.
|
|
430
|
-
*
|
|
431
|
-
* @ignore
|
|
432
|
-
* @protected
|
|
433
|
-
* @internal
|
|
434
|
-
*/
|
|
435
|
-
_autoscale(intervalCallback) {
|
|
436
|
-
// Don't scale if paused.
|
|
437
|
-
if (this.isStopped)
|
|
438
|
-
return intervalCallback();
|
|
439
|
-
// Only scale up if:
|
|
440
|
-
// - system has not been overloaded lately.
|
|
441
|
-
const systemStatus = this.systemStatus.getHistoricalStatus();
|
|
442
|
-
const { isSystemIdle } = systemStatus;
|
|
443
|
-
// - we're not already at max concurrency.
|
|
444
|
-
const weAreNotAtMax = this._desiredConcurrency < this._maxConcurrency;
|
|
445
|
-
// - current concurrency reaches at least the given ratio of desired concurrency.
|
|
446
|
-
const minCurrentConcurrency = Math.floor(this._desiredConcurrency * this.desiredConcurrencyRatio);
|
|
447
|
-
const weAreReachingDesiredConcurrency = this._currentConcurrency >= minCurrentConcurrency;
|
|
448
|
-
if (isSystemIdle && weAreNotAtMax && weAreReachingDesiredConcurrency)
|
|
449
|
-
this._scaleUp(systemStatus);
|
|
450
|
-
// Always scale down if:
|
|
451
|
-
// - the system has been overloaded lately.
|
|
452
|
-
const isSystemOverloaded = !isSystemIdle;
|
|
453
|
-
// - we're over min concurrency.
|
|
454
|
-
const weAreNotAtMin = this._desiredConcurrency > this._minConcurrency;
|
|
455
|
-
if (isSystemOverloaded && weAreNotAtMin)
|
|
456
|
-
this._scaleDown(systemStatus);
|
|
457
|
-
// On periodic intervals, print comprehensive log information
|
|
458
|
-
if (this.loggingIntervalMillis > 0) {
|
|
459
|
-
const now = Date.now();
|
|
460
|
-
if (now > this.lastLoggingTime + this.loggingIntervalMillis) {
|
|
461
|
-
this.lastLoggingTime = now;
|
|
462
|
-
this.log.info('state', {
|
|
463
|
-
currentConcurrency: this._currentConcurrency,
|
|
464
|
-
desiredConcurrency: this._desiredConcurrency,
|
|
465
|
-
systemStatus,
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
// Start a new interval cycle.
|
|
470
|
-
intervalCallback();
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Scales the pool up by increasing
|
|
474
|
-
* the desired concurrency by the scaleUpStepRatio.
|
|
475
|
-
*
|
|
476
|
-
* @param {Object} systemStatus for logging
|
|
477
|
-
* @ignore
|
|
478
|
-
* @protected
|
|
479
|
-
* @internal
|
|
480
|
-
*/
|
|
481
|
-
_scaleUp(systemStatus) {
|
|
482
|
-
const step = Math.ceil(this._desiredConcurrency * this.scaleUpStepRatio);
|
|
483
|
-
this._desiredConcurrency = Math.min(this._maxConcurrency, this._desiredConcurrency + step);
|
|
484
|
-
this.log.debug('scaling up', {
|
|
485
|
-
oldConcurrency: this._desiredConcurrency - step,
|
|
486
|
-
newConcurrency: this._desiredConcurrency,
|
|
487
|
-
systemStatus,
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Scales the pool down by decreasing
|
|
492
|
-
* the desired concurrency by the scaleDownStepRatio.
|
|
493
|
-
*
|
|
494
|
-
* @param {Object} systemStatus for logging
|
|
495
|
-
* @ignore
|
|
496
|
-
* @protected
|
|
497
|
-
* @internal
|
|
498
|
-
*/
|
|
499
|
-
_scaleDown(systemStatus) {
|
|
500
|
-
const step = Math.ceil(this._desiredConcurrency * this.scaleUpStepRatio);
|
|
501
|
-
this._desiredConcurrency = Math.max(this._minConcurrency, this._desiredConcurrency - step);
|
|
502
|
-
this.log.debug('scaling down', {
|
|
503
|
-
oldConcurrency: this._desiredConcurrency + step,
|
|
504
|
-
newConcurrency: this._desiredConcurrency,
|
|
505
|
-
systemStatus,
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* If there are no running tasks and this.isFinishedFunction() returns true then closes
|
|
510
|
-
* the pool and resolves the pool's promise returned by the run() method.
|
|
511
|
-
*
|
|
512
|
-
* It doesn't allow multiple concurrent runs of this method.
|
|
513
|
-
*
|
|
514
|
-
* @ignore
|
|
515
|
-
* @protected
|
|
516
|
-
* @internal
|
|
517
|
-
*/
|
|
518
|
-
async _maybeFinish() {
|
|
519
|
-
if (this.queryingIsFinished)
|
|
520
|
-
return;
|
|
521
|
-
if (this._currentConcurrency > 0)
|
|
522
|
-
return;
|
|
523
|
-
this.queryingIsFinished = true;
|
|
524
|
-
try {
|
|
525
|
-
const isFinished = await this.isFinishedFunction();
|
|
526
|
-
if (isFinished && this.resolve)
|
|
527
|
-
this.resolve();
|
|
528
|
-
}
|
|
529
|
-
catch (err) {
|
|
530
|
-
if (this.reject) {
|
|
531
|
-
// No need to log all concurrent errors.
|
|
532
|
-
this.log.exception(err, 'isFinishedFunction failed.');
|
|
533
|
-
this.reject(err);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
finally {
|
|
537
|
-
this.queryingIsFinished = false;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Cleans up resources.
|
|
542
|
-
*
|
|
543
|
-
* @ignore
|
|
544
|
-
* @protected
|
|
545
|
-
* @internal
|
|
546
|
-
*/
|
|
547
|
-
async _destroy() {
|
|
548
|
-
this.resolve = null;
|
|
549
|
-
this.reject = null;
|
|
550
|
-
(0, utilities_1.betterClearInterval)(this.autoscaleInterval);
|
|
551
|
-
(0, utilities_1.betterClearInterval)(this.maybeRunInterval);
|
|
552
|
-
if (this.snapshotter)
|
|
553
|
-
await this.snapshotter.stop();
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
exports.default = AutoscaledPool;
|
|
557
|
-
//# sourceMappingURL=autoscaled_pool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoscaled_pool.js","sourceRoot":"","sources":["../../src/autoscaling/autoscaled_pool.js"],"names":[],"mappings":";;;AAAA,4CAAqD;AACrD,gDAA0E;AAC1E,yDAAoB;AACpB,6EAAgE,CAAC,kDAAkD;AACnH,iFAAoE,CAAC,kDAAkD;AACvH,0EAA+C,CAAC,qCAAqC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,cAAc;IAChB;;;OAGG;IACH,YAAY,OAAO;QACf,IAAA,YAAE,EAAC,OAAO,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC;YAC7B,eAAe,EAAE,YAAE,CAAC,QAAQ;YAC5B,kBAAkB,EAAE,YAAE,CAAC,Q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