@crawlee/core 3.0.3-beta.1 → 3.0.3-beta.12
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/autoscaling/autoscaled_pool.d.ts +16 -16
- package/autoscaling/autoscaled_pool.js +13 -13
- package/autoscaling/snapshotter.d.ts +1 -1
- package/autoscaling/snapshotter.js +1 -1
- package/autoscaling/system_status.d.ts +12 -12
- package/autoscaling/system_status.js +11 -11
- package/configuration.d.ts +131 -7
- package/configuration.d.ts.map +1 -1
- package/configuration.js +27 -7
- package/configuration.js.map +1 -1
- package/crawlers/crawler_commons.d.ts +2 -2
- package/crawlers/statistics.d.ts +1 -1
- package/crawlers/statistics.js +1 -1
- package/enqueue_links/enqueue_links.d.ts +14 -13
- package/enqueue_links/enqueue_links.d.ts.map +1 -1
- package/enqueue_links/enqueue_links.js +6 -5
- package/enqueue_links/enqueue_links.js.map +1 -1
- package/enqueue_links/shared.d.ts +2 -2
- package/package.json +4 -4
- package/proxy_configuration.d.ts +11 -11
- package/proxy_configuration.js +8 -8
- package/request.d.ts +3 -3
- package/request.js +2 -2
- package/session_pool/session.d.ts +1 -1
- package/session_pool/session_pool.d.ts +12 -12
- package/session_pool/session_pool.d.ts.map +1 -1
- package/session_pool/session_pool.js +10 -10
- package/storages/dataset.d.ts +14 -14
- package/storages/dataset.js +8 -8
- package/storages/key_value_store.d.ts +28 -37
- package/storages/key_value_store.d.ts.map +1 -1
- package/storages/key_value_store.js +24 -33
- package/storages/key_value_store.js.map +1 -1
- package/storages/request_list.d.ts +33 -33
- package/storages/request_list.js +23 -23
- package/storages/request_queue.d.ts +25 -26
- package/storages/request_queue.d.ts.map +1 -1
- package/storages/request_queue.js +23 -24
- package/storages/request_queue.js.map +1 -1
- package/storages/utils.d.ts +1 -1
- package/storages/utils.js +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -20,7 +20,7 @@ export interface AutoscaledPoolOptions {
|
|
|
20
20
|
* If it resolves to `true` then the pool's run finishes. Being called only
|
|
21
21
|
* when there are no tasks being processed means that as long as `isTaskReadyFunction()`
|
|
22
22
|
* keeps resolving to `true`, `isFinishedFunction()` will never be called.
|
|
23
|
-
* To abort a run, use the {@
|
|
23
|
+
* To abort a run, use the {@apilink AutoscaledPool.abort} method.
|
|
24
24
|
*/
|
|
25
25
|
isFinishedFunction?: () => Promise<boolean>;
|
|
26
26
|
/**
|
|
@@ -84,12 +84,12 @@ export interface AutoscaledPoolOptions {
|
|
|
84
84
|
*/
|
|
85
85
|
taskTimeoutSecs?: number;
|
|
86
86
|
/**
|
|
87
|
-
* Options to be passed down to the {@
|
|
87
|
+
* Options to be passed down to the {@apilink Snapshotter} constructor. This is useful for fine-tuning
|
|
88
88
|
* the snapshot intervals and history.
|
|
89
89
|
*/
|
|
90
90
|
snapshotterOptions?: SnapshotterOptions;
|
|
91
91
|
/**
|
|
92
|
-
* Options to be passed down to the {@
|
|
92
|
+
* Options to be passed down to the {@apilink SystemStatus} constructor. This is useful for fine-tuning
|
|
93
93
|
* the system status reports. If a custom snapshotter is set in the options, it will be used
|
|
94
94
|
* by the pool.
|
|
95
95
|
*/
|
|
@@ -106,22 +106,22 @@ export interface AutoscaledPoolOptions {
|
|
|
106
106
|
* The pool only starts new tasks if there is enough free CPU and memory available
|
|
107
107
|
* and the Javascript event loop is not blocked.
|
|
108
108
|
*
|
|
109
|
-
* The information about the CPU and memory usage is obtained by the {@
|
|
109
|
+
* The information about the CPU and memory usage is obtained by the {@apilink Snapshotter} class,
|
|
110
110
|
* which makes regular snapshots of system resources that may be either local
|
|
111
111
|
* or from the Apify cloud infrastructure in case the process is running on the Apify platform.
|
|
112
|
-
* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the {@
|
|
112
|
+
* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the {@apilink SystemStatus} class.
|
|
113
113
|
*
|
|
114
114
|
* Before running the pool, you need to implement the following three functions:
|
|
115
|
-
* {@
|
|
116
|
-
* {@
|
|
117
|
-
* {@
|
|
115
|
+
* {@apilink AutoscaledPoolOptions.runTaskFunction},
|
|
116
|
+
* {@apilink AutoscaledPoolOptions.isTaskReadyFunction} and
|
|
117
|
+
* {@apilink AutoscaledPoolOptions.isFinishedFunction}.
|
|
118
118
|
*
|
|
119
|
-
* The auto-scaled pool is started by calling the {@
|
|
120
|
-
* The pool periodically queries the {@
|
|
119
|
+
* The auto-scaled pool is started by calling the {@apilink AutoscaledPool.run} function.
|
|
120
|
+
* The pool periodically queries the {@apilink AutoscaledPoolOptions.isTaskReadyFunction} function
|
|
121
121
|
* for more tasks, managing optimal concurrency, until the function resolves to `false`. The pool then queries
|
|
122
|
-
* the {@
|
|
122
|
+
* the {@apilink AutoscaledPoolOptions.isFinishedFunction}. If it resolves to `true`, the run finishes after all running tasks complete.
|
|
123
123
|
* If it resolves to `false`, it assumes there will be more tasks available later and keeps periodically querying for tasks.
|
|
124
|
-
* If any of the tasks throws then the {@
|
|
124
|
+
* If any of the tasks throws then the {@apilink AutoscaledPool.run} function rejects the promise with an error.
|
|
125
125
|
*
|
|
126
126
|
* The pool evaluates whether it should start a new task every time one of the tasks finishes
|
|
127
127
|
* and also in the interval set by the `options.maybeRunIntervalSecs` parameter.
|
|
@@ -221,7 +221,7 @@ export declare class AutoscaledPool {
|
|
|
221
221
|
run(): Promise<void>;
|
|
222
222
|
/**
|
|
223
223
|
* Aborts the run of the auto-scaled pool and destroys it. The promise returned from
|
|
224
|
-
* the {@
|
|
224
|
+
* the {@apilink AutoscaledPool.run} function will immediately resolve, no more new tasks
|
|
225
225
|
* will be spawned and all running tasks will be left in their current state.
|
|
226
226
|
*
|
|
227
227
|
* Due to the nature of the tasks, auto-scaled pool cannot reliably guarantee abortion
|
|
@@ -233,19 +233,19 @@ export declare class AutoscaledPool {
|
|
|
233
233
|
abort(): Promise<void>;
|
|
234
234
|
/**
|
|
235
235
|
* Prevents the auto-scaled pool from starting new tasks, but allows the running ones to finish
|
|
236
|
-
* (unlike abort, which terminates them). Used together with {@
|
|
236
|
+
* (unlike abort, which terminates them). Used together with {@apilink AutoscaledPool.resume}
|
|
237
237
|
*
|
|
238
238
|
* The function's promise will resolve once all running tasks have completed and the pool
|
|
239
239
|
* is effectively idle. If the `timeoutSecs` argument is provided, the promise will reject
|
|
240
240
|
* with a timeout error after the `timeoutSecs` seconds.
|
|
241
241
|
*
|
|
242
|
-
* The promise returned from the {@
|
|
242
|
+
* The promise returned from the {@apilink AutoscaledPool.run} function will not resolve
|
|
243
243
|
* when `.pause()` is invoked (unlike abort, which resolves it).
|
|
244
244
|
*/
|
|
245
245
|
pause(timeoutSecs?: number): Promise<void>;
|
|
246
246
|
/**
|
|
247
247
|
* Resumes the operation of the autoscaled-pool by allowing more tasks to be run.
|
|
248
|
-
* Used together with {@
|
|
248
|
+
* Used together with {@apilink AutoscaledPool.pause}
|
|
249
249
|
*
|
|
250
250
|
* Tasks will automatically start running again in `options.maybeRunIntervalSecs`.
|
|
251
251
|
*/
|
|
@@ -14,22 +14,22 @@ const system_status_1 = require("./system_status");
|
|
|
14
14
|
* The pool only starts new tasks if there is enough free CPU and memory available
|
|
15
15
|
* and the Javascript event loop is not blocked.
|
|
16
16
|
*
|
|
17
|
-
* The information about the CPU and memory usage is obtained by the {@
|
|
17
|
+
* The information about the CPU and memory usage is obtained by the {@apilink Snapshotter} class,
|
|
18
18
|
* which makes regular snapshots of system resources that may be either local
|
|
19
19
|
* or from the Apify cloud infrastructure in case the process is running on the Apify platform.
|
|
20
|
-
* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the {@
|
|
20
|
+
* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the {@apilink SystemStatus} class.
|
|
21
21
|
*
|
|
22
22
|
* Before running the pool, you need to implement the following three functions:
|
|
23
|
-
* {@
|
|
24
|
-
* {@
|
|
25
|
-
* {@
|
|
23
|
+
* {@apilink AutoscaledPoolOptions.runTaskFunction},
|
|
24
|
+
* {@apilink AutoscaledPoolOptions.isTaskReadyFunction} and
|
|
25
|
+
* {@apilink AutoscaledPoolOptions.isFinishedFunction}.
|
|
26
26
|
*
|
|
27
|
-
* The auto-scaled pool is started by calling the {@
|
|
28
|
-
* The pool periodically queries the {@
|
|
27
|
+
* The auto-scaled pool is started by calling the {@apilink AutoscaledPool.run} function.
|
|
28
|
+
* The pool periodically queries the {@apilink AutoscaledPoolOptions.isTaskReadyFunction} function
|
|
29
29
|
* for more tasks, managing optimal concurrency, until the function resolves to `false`. The pool then queries
|
|
30
|
-
* the {@
|
|
30
|
+
* the {@apilink AutoscaledPoolOptions.isFinishedFunction}. If it resolves to `true`, the run finishes after all running tasks complete.
|
|
31
31
|
* If it resolves to `false`, it assumes there will be more tasks available later and keeps periodically querying for tasks.
|
|
32
|
-
* If any of the tasks throws then the {@
|
|
32
|
+
* If any of the tasks throws then the {@apilink AutoscaledPool.run} function rejects the promise with an error.
|
|
33
33
|
*
|
|
34
34
|
* The pool evaluates whether it should start a new task every time one of the tasks finishes
|
|
35
35
|
* and also in the interval set by the `options.maybeRunIntervalSecs` parameter.
|
|
@@ -378,7 +378,7 @@ class AutoscaledPool {
|
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Aborts the run of the auto-scaled pool and destroys it. The promise returned from
|
|
381
|
-
* the {@
|
|
381
|
+
* the {@apilink AutoscaledPool.run} function will immediately resolve, no more new tasks
|
|
382
382
|
* will be spawned and all running tasks will be left in their current state.
|
|
383
383
|
*
|
|
384
384
|
* Due to the nature of the tasks, auto-scaled pool cannot reliably guarantee abortion
|
|
@@ -396,13 +396,13 @@ class AutoscaledPool {
|
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
398
|
* Prevents the auto-scaled pool from starting new tasks, but allows the running ones to finish
|
|
399
|
-
* (unlike abort, which terminates them). Used together with {@
|
|
399
|
+
* (unlike abort, which terminates them). Used together with {@apilink AutoscaledPool.resume}
|
|
400
400
|
*
|
|
401
401
|
* The function's promise will resolve once all running tasks have completed and the pool
|
|
402
402
|
* is effectively idle. If the `timeoutSecs` argument is provided, the promise will reject
|
|
403
403
|
* with a timeout error after the `timeoutSecs` seconds.
|
|
404
404
|
*
|
|
405
|
-
* The promise returned from the {@
|
|
405
|
+
* The promise returned from the {@apilink AutoscaledPool.run} function will not resolve
|
|
406
406
|
* when `.pause()` is invoked (unlike abort, which resolves it).
|
|
407
407
|
*/
|
|
408
408
|
async pause(timeoutSecs) {
|
|
@@ -431,7 +431,7 @@ class AutoscaledPool {
|
|
|
431
431
|
}
|
|
432
432
|
/**
|
|
433
433
|
* Resumes the operation of the autoscaled-pool by allowing more tasks to be run.
|
|
434
|
-
* Used together with {@
|
|
434
|
+
* Used together with {@apilink AutoscaledPool.pause}
|
|
435
435
|
*
|
|
436
436
|
* Tasks will automatically start running again in `options.maybeRunIntervalSecs`.
|
|
437
437
|
*/
|
|
@@ -75,7 +75,7 @@ interface ClientSnapshot {
|
|
|
75
75
|
* Creates snapshots of system resources at given intervals and marks the resource
|
|
76
76
|
* as either overloaded or not during the last interval. Keeps a history of the snapshots.
|
|
77
77
|
* It tracks the following resources: Memory, EventLoop, API and CPU.
|
|
78
|
-
* The class is used by the {@
|
|
78
|
+
* The class is used by the {@apilink AutoscaledPool} class.
|
|
79
79
|
*
|
|
80
80
|
* When running on the Apify platform, the CPU and memory statistics are provided by the platform,
|
|
81
81
|
* as collected from the running Docker container. When running locally, `Snapshotter`
|
|
@@ -14,7 +14,7 @@ const CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS = 10000;
|
|
|
14
14
|
* Creates snapshots of system resources at given intervals and marks the resource
|
|
15
15
|
* as either overloaded or not during the last interval. Keeps a history of the snapshots.
|
|
16
16
|
* It tracks the following resources: Memory, EventLoop, API and CPU.
|
|
17
|
-
* The class is used by the {@
|
|
17
|
+
* The class is used by the {@apilink AutoscaledPool} class.
|
|
18
18
|
*
|
|
19
19
|
* When running on the Apify platform, the CPU and memory statistics are provided by the platform,
|
|
20
20
|
* as collected from the running Docker container. When running locally, `Snapshotter`
|
|
@@ -29,7 +29,7 @@ export interface SystemInfo {
|
|
|
29
29
|
}
|
|
30
30
|
export interface SystemStatusOptions {
|
|
31
31
|
/**
|
|
32
|
-
* Defines max age of snapshots used in the {@
|
|
32
|
+
* Defines max age of snapshots used in the {@apilink SystemStatus.getCurrentStatus} measurement.
|
|
33
33
|
* @default 5
|
|
34
34
|
*/
|
|
35
35
|
currentHistorySecs?: number;
|
|
@@ -82,25 +82,25 @@ export interface FinalStatistics {
|
|
|
82
82
|
crawlerRuntimeMillis: number;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Provides a simple interface to reading system status from a {@
|
|
86
|
-
* It only exposes two functions {@
|
|
87
|
-
* and {@
|
|
85
|
+
* Provides a simple interface to reading system status from a {@apilink Snapshotter} instance.
|
|
86
|
+
* It only exposes two functions {@apilink SystemStatus.getCurrentStatus}
|
|
87
|
+
* and {@apilink SystemStatus.getHistoricalStatus}.
|
|
88
88
|
* The system status is calculated using a weighted average of overloaded
|
|
89
89
|
* messages in the snapshots, with the weights being the time intervals
|
|
90
90
|
* between the snapshots. Each resource is calculated separately
|
|
91
91
|
* and the system is overloaded whenever at least one resource is overloaded.
|
|
92
|
-
* The class is used by the {@
|
|
92
|
+
* The class is used by the {@apilink AutoscaledPool} class.
|
|
93
93
|
*
|
|
94
|
-
* {@
|
|
94
|
+
* {@apilink SystemStatus.getCurrentStatus}
|
|
95
95
|
* returns a boolean that represents the current status of the system.
|
|
96
96
|
* The length of the current timeframe in seconds is configurable
|
|
97
97
|
* by the `currentHistorySecs` option and represents the max age
|
|
98
98
|
* of snapshots to be considered for the calculation.
|
|
99
99
|
*
|
|
100
|
-
* {@
|
|
100
|
+
* {@apilink SystemStatus.getHistoricalStatus}
|
|
101
101
|
* returns a boolean that represents the long-term status
|
|
102
102
|
* of the system. It considers the full snapshot history available
|
|
103
|
-
* in the {@
|
|
103
|
+
* in the {@apilink Snapshotter} instance.
|
|
104
104
|
* @category Scaling
|
|
105
105
|
*/
|
|
106
106
|
export declare class SystemStatus {
|
|
@@ -112,7 +112,7 @@ export declare class SystemStatus {
|
|
|
112
112
|
private readonly snapshotter;
|
|
113
113
|
constructor(options?: SystemStatusOptions);
|
|
114
114
|
/**
|
|
115
|
-
* Returns an {@
|
|
115
|
+
* Returns an {@apilink SystemInfo} object with the following structure:
|
|
116
116
|
*
|
|
117
117
|
* ```javascript
|
|
118
118
|
* {
|
|
@@ -129,7 +129,7 @@ export declare class SystemStatus {
|
|
|
129
129
|
*/
|
|
130
130
|
getCurrentStatus(): SystemInfo;
|
|
131
131
|
/**
|
|
132
|
-
* Returns an {@
|
|
132
|
+
* Returns an {@apilink SystemInfo} object with the following structure:
|
|
133
133
|
*
|
|
134
134
|
* ```javascript
|
|
135
135
|
* {
|
|
@@ -141,8 +141,8 @@ export declare class SystemStatus {
|
|
|
141
141
|
* ```
|
|
142
142
|
*
|
|
143
143
|
* Where the `isSystemIdle` property is set to `false` if the system
|
|
144
|
-
* has been overloaded in the full history of the {@
|
|
145
|
-
* (which is configurable in the {@
|
|
144
|
+
* has been overloaded in the full history of the {@apilink Snapshotter}
|
|
145
|
+
* (which is configurable in the {@apilink Snapshotter}) and `true` otherwise.
|
|
146
146
|
*/
|
|
147
147
|
getHistoricalStatus(): SystemInfo;
|
|
148
148
|
/**
|
|
@@ -6,25 +6,25 @@ const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
|
6
6
|
const utils_1 = require("@crawlee/utils");
|
|
7
7
|
const snapshotter_1 = require("./snapshotter");
|
|
8
8
|
/**
|
|
9
|
-
* Provides a simple interface to reading system status from a {@
|
|
10
|
-
* It only exposes two functions {@
|
|
11
|
-
* and {@
|
|
9
|
+
* Provides a simple interface to reading system status from a {@apilink Snapshotter} instance.
|
|
10
|
+
* It only exposes two functions {@apilink SystemStatus.getCurrentStatus}
|
|
11
|
+
* and {@apilink SystemStatus.getHistoricalStatus}.
|
|
12
12
|
* The system status is calculated using a weighted average of overloaded
|
|
13
13
|
* messages in the snapshots, with the weights being the time intervals
|
|
14
14
|
* between the snapshots. Each resource is calculated separately
|
|
15
15
|
* and the system is overloaded whenever at least one resource is overloaded.
|
|
16
|
-
* The class is used by the {@
|
|
16
|
+
* The class is used by the {@apilink AutoscaledPool} class.
|
|
17
17
|
*
|
|
18
|
-
* {@
|
|
18
|
+
* {@apilink SystemStatus.getCurrentStatus}
|
|
19
19
|
* returns a boolean that represents the current status of the system.
|
|
20
20
|
* The length of the current timeframe in seconds is configurable
|
|
21
21
|
* by the `currentHistorySecs` option and represents the max age
|
|
22
22
|
* of snapshots to be considered for the calculation.
|
|
23
23
|
*
|
|
24
|
-
* {@
|
|
24
|
+
* {@apilink SystemStatus.getHistoricalStatus}
|
|
25
25
|
* returns a boolean that represents the long-term status
|
|
26
26
|
* of the system. It considers the full snapshot history available
|
|
27
|
-
* in the {@
|
|
27
|
+
* in the {@apilink Snapshotter} instance.
|
|
28
28
|
* @category Scaling
|
|
29
29
|
*/
|
|
30
30
|
class SystemStatus {
|
|
@@ -83,7 +83,7 @@ class SystemStatus {
|
|
|
83
83
|
this.snapshotter = snapshotter || new snapshotter_1.Snapshotter({ config });
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Returns an {@
|
|
86
|
+
* Returns an {@apilink SystemInfo} object with the following structure:
|
|
87
87
|
*
|
|
88
88
|
* ```javascript
|
|
89
89
|
* {
|
|
@@ -102,7 +102,7 @@ class SystemStatus {
|
|
|
102
102
|
return this._isSystemIdle(this.currentHistorySecs);
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* Returns an {@
|
|
105
|
+
* Returns an {@apilink SystemInfo} object with the following structure:
|
|
106
106
|
*
|
|
107
107
|
* ```javascript
|
|
108
108
|
* {
|
|
@@ -114,8 +114,8 @@ class SystemStatus {
|
|
|
114
114
|
* ```
|
|
115
115
|
*
|
|
116
116
|
* Where the `isSystemIdle` property is set to `false` if the system
|
|
117
|
-
* has been overloaded in the full history of the {@
|
|
118
|
-
* (which is configurable in the {@
|
|
117
|
+
* has been overloaded in the full history of the {@apilink Snapshotter}
|
|
118
|
+
* (which is configurable in the {@apilink Snapshotter}) and `true` otherwise.
|
|
119
119
|
*/
|
|
120
120
|
getHistoricalStatus() {
|
|
121
121
|
return this._isSystemIdle();
|
package/configuration.d.ts
CHANGED
|
@@ -6,44 +6,168 @@ import type { Dictionary, StorageClient } from '@crawlee/types';
|
|
|
6
6
|
import { LogLevel } from '@apify/log';
|
|
7
7
|
import type { EventManager } from './events';
|
|
8
8
|
export interface ConfigurationOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Defines storage client to be used.
|
|
11
|
+
* @default {@apilink MemoryStorage}
|
|
12
|
+
*/
|
|
9
13
|
storageClient?: StorageClient;
|
|
14
|
+
/**
|
|
15
|
+
* Defines the Event Manager to be used.
|
|
16
|
+
* @default {@apilink EventManager}
|
|
17
|
+
*/
|
|
10
18
|
eventManager?: EventManager;
|
|
19
|
+
/**
|
|
20
|
+
* Could be used to adjust the storage client behavior
|
|
21
|
+
* e.g. {@apilink MemoryStorageOptions} could be used to adjust the {@apilink MemoryStorage} behavior.
|
|
22
|
+
*/
|
|
11
23
|
storageClientOptions?: Dictionary;
|
|
24
|
+
/**
|
|
25
|
+
* Default dataset id.
|
|
26
|
+
*
|
|
27
|
+
* Alternative to `CRAWLEE_DEFAULT_DATASET_ID` environment variable.
|
|
28
|
+
* @default 'default'
|
|
29
|
+
*/
|
|
12
30
|
defaultDatasetId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Defines whether to purge the default storage folders before starting the crawler run.
|
|
33
|
+
*
|
|
34
|
+
* Alternative to `CRAWLEE_PURGE_ON_START` environment variable.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
13
37
|
purgeOnStart?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Default key-value store id.
|
|
40
|
+
*
|
|
41
|
+
* Alternative to `CRAWLEE_DEFAULT_KEY_VALUE_STORE_ID` environment variable.
|
|
42
|
+
* @default 'default'
|
|
43
|
+
*/
|
|
14
44
|
defaultKeyValueStoreId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Default request queue id.
|
|
47
|
+
*
|
|
48
|
+
* Alternative to `CRAWLEE_DEFAULT_REQUEST_QUEUE_ID` environment variable.
|
|
49
|
+
* @default 'default'
|
|
50
|
+
*/
|
|
15
51
|
defaultRequestQueueId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Sets the ratio, defining the maximum CPU usage.
|
|
54
|
+
* When the CPU usage is higher than the provided ratio, the CPU is considered overloaded.
|
|
55
|
+
* @default 0.95
|
|
56
|
+
*/
|
|
16
57
|
maxUsedCpuRatio?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the ratio, defining the amount of system memory that could be used by the {@apilink AutoscaledPool}.
|
|
60
|
+
* When the memory usage is more than the provided ratio, the memory is considered overloaded.
|
|
61
|
+
*
|
|
62
|
+
* Alternative to `CRAWLEE_AVAILABLE_MEMORY_RATIO` environment variable.
|
|
63
|
+
* @default 0.25
|
|
64
|
+
*/
|
|
17
65
|
availableMemoryRatio?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the amount of system memory in megabytes to be used by the {@apilink AutoscaledPool}.
|
|
68
|
+
* By default, the maximum memory is set to one quarter of total system memory.
|
|
69
|
+
*
|
|
70
|
+
* Alternative to `CRAWLEE_MEMORY_MBYTES` environment variable.
|
|
71
|
+
*/
|
|
18
72
|
memoryMbytes?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Defines the interval of emitting the `persistState` event.
|
|
75
|
+
*
|
|
76
|
+
* Alternative to `CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS` environment variable.
|
|
77
|
+
* @default 60_000
|
|
78
|
+
*/
|
|
19
79
|
persistStateIntervalMillis?: number;
|
|
80
|
+
/**
|
|
81
|
+
Defines the interval of emitting the `systemInfo` event.
|
|
82
|
+
@default 60_000
|
|
83
|
+
*/
|
|
20
84
|
systemInfoIntervalMillis?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Defines the default input key, i.e. the key that is used to get the crawler input value
|
|
87
|
+
* from the default {@apilink KeyValueStore} associated with the current crawler run.
|
|
88
|
+
*
|
|
89
|
+
* Alternative to `CRAWLEE_INPUT_KEY` environment variable.
|
|
90
|
+
* @default 'INPUT'
|
|
91
|
+
*/
|
|
21
92
|
inputKey?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Defines whether web browsers launched by Crawlee will run in the headless mode.
|
|
95
|
+
*
|
|
96
|
+
* Alternative to `CRAWLEE_HEADLESS` environment variable.
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
22
99
|
headless?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Defines whether to run X virtual framebuffer on the web browsers launched by Crawlee.
|
|
102
|
+
*
|
|
103
|
+
* Alternative to `CRAWLEE_XVFB` environment variable.
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
23
106
|
xvfb?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Defines a path to Chrome executable.
|
|
109
|
+
*
|
|
110
|
+
* Alternative to `CRAWLEE_CHROME_EXECUTABLE_PATH` environment variable.
|
|
111
|
+
*/
|
|
24
112
|
chromeExecutablePath?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Defines a path to default browser executable.
|
|
115
|
+
*
|
|
116
|
+
* Alternative to `CRAWLEE_DEFAULT_BROWSER_PATH` environment variable.
|
|
117
|
+
*/
|
|
25
118
|
defaultBrowserPath?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Defines whether to disable browser sandbox by adding `--no-sandbox` flag to `launchOptions`.
|
|
121
|
+
*
|
|
122
|
+
* Alternative to `CRAWLEE_DISABLE_BROWSER_SANDBOX` environment variable.
|
|
123
|
+
*/
|
|
26
124
|
disableBrowserSandbox?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Sets the log level to the given value.
|
|
127
|
+
*
|
|
128
|
+
* Alternative to `CRAWLEE_LOG_LEVEL`.
|
|
129
|
+
* @default 'INFO'
|
|
130
|
+
*/
|
|
27
131
|
logLevel?: LogLevel | LogLevel[keyof LogLevel];
|
|
28
132
|
}
|
|
29
133
|
/**
|
|
30
134
|
* `Configuration` is a value object holding Crawlee configuration. By default, there is a
|
|
31
135
|
* global singleton instance of this class available via `Configuration.getGlobalConfig()`.
|
|
32
|
-
* Places that depend on a configurable behaviour depend on this class as have the global
|
|
136
|
+
* Places that depend on a configurable behaviour depend on this class, as they have the global
|
|
33
137
|
* instance as the default value.
|
|
34
138
|
*
|
|
139
|
+
* *Using global configuration:*
|
|
35
140
|
* ```js
|
|
36
141
|
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
37
142
|
*
|
|
143
|
+
* // Get the global configuration
|
|
144
|
+
* const config = Configuration.getGlobalConfig();
|
|
145
|
+
* // Set the 'persistStateIntervalMillis' option
|
|
146
|
+
* // of global configuration to 10 seconds
|
|
147
|
+
* config.set('persistStateIntervalMillis', 10_000);
|
|
148
|
+
*
|
|
149
|
+
* // No need to pass the configuration to the crawler,
|
|
150
|
+
* // as it's using the global configuration by default
|
|
151
|
+
* const crawler = new BasicCrawler();
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* *Using custom configuration:*
|
|
155
|
+
* ```js
|
|
156
|
+
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
157
|
+
*
|
|
158
|
+
* // Create a new configuration
|
|
38
159
|
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
160
|
+
* // Pass the configuration to the crawler
|
|
39
161
|
* const crawler = new BasicCrawler({ ... }, config);
|
|
40
162
|
* ```
|
|
41
163
|
*
|
|
42
164
|
* The configuration provided via environment variables always takes precedence. We can also
|
|
43
165
|
* define the `crawlee.json` file in the project root directory which will serve as a baseline,
|
|
44
|
-
* so the options provided in constructor will override those.
|
|
166
|
+
* so the options provided in constructor will override those. In other words, the precedence is:
|
|
45
167
|
*
|
|
46
|
-
*
|
|
168
|
+
* ```text
|
|
169
|
+
* crawlee.json < constructor options < environment variables
|
|
170
|
+
* ```
|
|
47
171
|
*
|
|
48
172
|
* ## Supported Configuration Options
|
|
49
173
|
*
|
|
@@ -100,8 +224,8 @@ export declare class Configuration {
|
|
|
100
224
|
*/
|
|
101
225
|
set(key: keyof ConfigurationOptions, value?: any): void;
|
|
102
226
|
/**
|
|
103
|
-
* Returns cached instance of {@
|
|
104
|
-
* this {@
|
|
227
|
+
* Returns cached instance of {@apilink StorageClient} using options as defined in the environment variables or in
|
|
228
|
+
* this {@apilink Configuration} instance. Only first call of this method will create the client, following calls will
|
|
105
229
|
* return the same client instance.
|
|
106
230
|
*
|
|
107
231
|
* Caching works based on the `storageClientOptions`, so calling this method with different options will return
|
|
@@ -122,11 +246,11 @@ export declare class Configuration {
|
|
|
122
246
|
*/
|
|
123
247
|
static getGlobalConfig(): Configuration;
|
|
124
248
|
/**
|
|
125
|
-
* Gets default {@
|
|
249
|
+
* Gets default {@apilink StorageClient} instance.
|
|
126
250
|
*/
|
|
127
251
|
static getStorageClient(): StorageClient;
|
|
128
252
|
/**
|
|
129
|
-
* Gets default {@
|
|
253
|
+
* Gets default {@apilink EventManager} instance.
|
|
130
254
|
*/
|
|
131
255
|
static getEventManager(): EventManager;
|
|
132
256
|
/**
|
package/configuration.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,MAAM,WAAW,oBA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,EAAE,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAIvD;;;;;;;;OAQG;IACH,gBAAgB,IAAI,aAAa;IASjC,eAAe,IAAI,YAAY;IAe/B;;;OAGG;IACH,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa;IAatE,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAI7C,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAI3C;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,aAAa;IASvC;;OAEG;IACH,MAAM,CAAC,gBAAgB,IAAI,aAAa;IAIxC;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,YAAY;IAItC;;;OAGG;IACH,MAAM,CAAC,gBAAgB,IAAI,IAAI;IAI/B,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,oBAAoB;CAgBvD"}
|
package/configuration.js
CHANGED
|
@@ -13,21 +13,41 @@ const events_1 = require("./events");
|
|
|
13
13
|
/**
|
|
14
14
|
* `Configuration` is a value object holding Crawlee configuration. By default, there is a
|
|
15
15
|
* global singleton instance of this class available via `Configuration.getGlobalConfig()`.
|
|
16
|
-
* Places that depend on a configurable behaviour depend on this class as have the global
|
|
16
|
+
* Places that depend on a configurable behaviour depend on this class, as they have the global
|
|
17
17
|
* instance as the default value.
|
|
18
18
|
*
|
|
19
|
+
* *Using global configuration:*
|
|
19
20
|
* ```js
|
|
20
21
|
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
21
22
|
*
|
|
23
|
+
* // Get the global configuration
|
|
24
|
+
* const config = Configuration.getGlobalConfig();
|
|
25
|
+
* // Set the 'persistStateIntervalMillis' option
|
|
26
|
+
* // of global configuration to 10 seconds
|
|
27
|
+
* config.set('persistStateIntervalMillis', 10_000);
|
|
28
|
+
*
|
|
29
|
+
* // No need to pass the configuration to the crawler,
|
|
30
|
+
* // as it's using the global configuration by default
|
|
31
|
+
* const crawler = new BasicCrawler();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* *Using custom configuration:*
|
|
35
|
+
* ```js
|
|
36
|
+
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
37
|
+
*
|
|
38
|
+
* // Create a new configuration
|
|
22
39
|
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
40
|
+
* // Pass the configuration to the crawler
|
|
23
41
|
* const crawler = new BasicCrawler({ ... }, config);
|
|
24
42
|
* ```
|
|
25
43
|
*
|
|
26
44
|
* The configuration provided via environment variables always takes precedence. We can also
|
|
27
45
|
* define the `crawlee.json` file in the project root directory which will serve as a baseline,
|
|
28
|
-
* so the options provided in constructor will override those.
|
|
46
|
+
* so the options provided in constructor will override those. In other words, the precedence is:
|
|
29
47
|
*
|
|
30
|
-
*
|
|
48
|
+
* ```text
|
|
49
|
+
* crawlee.json < constructor options < environment variables
|
|
50
|
+
* ```
|
|
31
51
|
*
|
|
32
52
|
* ## Supported Configuration Options
|
|
33
53
|
*
|
|
@@ -121,8 +141,8 @@ class Configuration {
|
|
|
121
141
|
this.options.set(key, value);
|
|
122
142
|
}
|
|
123
143
|
/**
|
|
124
|
-
* Returns cached instance of {@
|
|
125
|
-
* this {@
|
|
144
|
+
* Returns cached instance of {@apilink StorageClient} using options as defined in the environment variables or in
|
|
145
|
+
* this {@apilink Configuration} instance. Only first call of this method will create the client, following calls will
|
|
126
146
|
* return the same client instance.
|
|
127
147
|
*
|
|
128
148
|
* Caching works based on the `storageClientOptions`, so calling this method with different options will return
|
|
@@ -177,13 +197,13 @@ class Configuration {
|
|
|
177
197
|
return Configuration.globalConfig;
|
|
178
198
|
}
|
|
179
199
|
/**
|
|
180
|
-
* Gets default {@
|
|
200
|
+
* Gets default {@apilink StorageClient} instance.
|
|
181
201
|
*/
|
|
182
202
|
static getStorageClient() {
|
|
183
203
|
return this.getGlobalConfig().getStorageClient();
|
|
184
204
|
}
|
|
185
205
|
/**
|
|
186
|
-
* Gets default {@
|
|
206
|
+
* Gets default {@apilink EventManager} instance.
|
|
187
207
|
*/
|
|
188
208
|
static getEventManager() {
|
|
189
209
|
return this.getGlobalConfig().getEventManager();
|
package/configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;AACA,4DAAwD;AACxD,uCAAwD;AACxD,yCAAiC;AACjC,uDAAqD;AACrD,6CAA2C;AAE3C,0DAA2C;AAC3C,yCAAqC;AAErC,qCAA6C;
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;AACA,4DAAwD;AACxD,uCAAwD;AACxD,yCAAiC;AACjC,uDAAqD;AACrD,6CAA2C;AAE3C,0DAA2C;AAC3C,yCAAqC;AAErC,qCAA6C;AAkJ7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAa,aAAa;IAmDtB;;OAEG;IACH,YAAY,UAAgC,EAAE;QAT9C;;;;;WAAsG;QACtG;;;;mBAAqB,IAAI,GAAG,EAAmB;WAAC;QAS5C,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE3B,oEAAoE;QACpE,0BAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;QAEtC,6DAA6D;QAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,QAAQ,EAAE;YACV,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAyB,CAAC,CAAC;YACvH,aAAG,CAAC,QAAQ,CAAC,KAAiB,CAAC,CAAC;SACnC;IACL,CAAC;IAED;;;;OAIG;IACH,GAAG,C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AAC,MAAM;gBACJ,SAAS;aACZ;SACJ;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;;AArOL,sCAsOC;AArOG;;GAEG;AACH;;;;WAAuC;QACnC,8BAA8B,EAAE,sBAAsB;QACtD,sBAAsB,EAAE,cAAc;QACtC,qBAAqB,EAAE,cAAc;QACrC,0BAA0B,EAAE,kBAAkB;QAC9C,kCAAkC,EAAE,wBAAwB;QAC5D,gCAAgC,EAAE,uBAAuB;QACzD,iBAAiB,EAAE,UAAU;QAC7B,qCAAqC,EAAE,4BAA4B;QACnE,gBAAgB,EAAE,UAAU;QAC5B,YAAY,EAAE,MAAM;QACpB,8BAA8B,EAAE,sBAAsB;QACtD,4BAA4B,EAAE,oBAAoB;QAClD,+BAA+B,EAAE,uBAAuB;QACxD,iBAAiB,EAAE,UAAU;KAChC;GAAC;AAEF;;;;WAAgC,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,uBAAuB,CAAC;GAAC;AAE9F;;;;WAAgC,CAAC,cAAc,EAAE,4BAA4B,EAAE,0BAA0B,CAAC;GAAC;AAE3G;;;;WAAwC;QACpC,sBAAsB,EAAE,SAAS;QACjC,gBAAgB,EAAE,SAAS;QAC3B,qBAAqB,EAAE,SAAS;QAChC,QAAQ,EAAE,OAAO;QACjB,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,IAAI;QAC1B,oBAAoB,EAAE,EAAE;QACxB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;QACd,0BAA0B,EAAE,KAAM;QAClC,wBAAwB,EAAE,KAAM;KACnC;GAAC;AAEF;;;GAGG;AACH;;;;WAAiB,IAAI,oCAAiB,EAAiB;GAAC"}
|
|
@@ -6,13 +6,13 @@ import type { Session } from '../session_pool/session';
|
|
|
6
6
|
export interface CrawlingContext<UserData extends Dictionary = Dictionary> extends Record<PropertyKey, unknown> {
|
|
7
7
|
id: string;
|
|
8
8
|
/**
|
|
9
|
-
* The original {@
|
|
9
|
+
* The original {@apilink Request} object.
|
|
10
10
|
*/
|
|
11
11
|
request: Request<UserData>;
|
|
12
12
|
session?: Session;
|
|
13
13
|
/**
|
|
14
14
|
* An object with information about currently used proxy by the crawler
|
|
15
|
-
* and configured by the {@
|
|
15
|
+
* and configured by the {@apilink ProxyConfiguration} class.
|
|
16
16
|
*/
|
|
17
17
|
proxyInfo?: ProxyInfo;
|
|
18
18
|
log: Log;
|
package/crawlers/statistics.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class Statistics {
|
|
|
28
28
|
*/
|
|
29
29
|
readonly id: number;
|
|
30
30
|
/**
|
|
31
|
-
* Current statistic state used for doing calculations on {@
|
|
31
|
+
* Current statistic state used for doing calculations on {@apilink Statistics.calculate} calls
|
|
32
32
|
*/
|
|
33
33
|
state: StatisticState;
|
|
34
34
|
/**
|
package/crawlers/statistics.js
CHANGED
|
@@ -67,7 +67,7 @@ class Statistics {
|
|
|
67
67
|
value: Statistics.id++
|
|
68
68
|
}); // assign an id while incrementing so it can be saved/restored from KV
|
|
69
69
|
/**
|
|
70
|
-
* Current statistic state used for doing calculations on {@
|
|
70
|
+
* Current statistic state used for doing calculations on {@apilink Statistics.calculate} calls
|
|
71
71
|
*/
|
|
72
72
|
Object.defineProperty(this, "state", {
|
|
73
73
|
enumerable: true,
|