You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cb(null, {"foo":"bar"}); // output must be compatible with JSON.stringify
28
29
};
29
30
30
-
var worker =newStepFunctionWorker({
31
+
constworker=newStepFunctionWorker({
31
32
activityArn :'<activity-ARN>',
32
33
workerName :'workerName',
33
34
fn : fn,
34
-
concurrency :2// default is 1
35
+
taskConcurrency :22, // default is null = Infinity
36
+
poolConcurrency :2// default is 1
35
37
});
36
38
```
39
+
40
+
### Concurrency management
41
+
42
+
Since version **3.0**, `concurrency` has been replaced by `poolConcurrency` and `taskConcurrency`.
43
+
44
+
*`taskConcurrency` (`null` means Infinite)
45
+
46
+
It represent the maximum number of parallel tasks done by the worker (default: `null`).
47
+
48
+
*`poolConcurrency` is the maximum number of parallel getActivity, http request (see [`sdk.getActivity`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/StepFunctions.html#getActivityTask-property)) (default: `1`)
49
+
50
+
Increase this to have a more responsive worker.
51
+
52
+
Anyway, you should always have `poolConcurrency` < `taskConcurrency`.
53
+
37
54
#### Set the Region
38
55
39
56
By default, this package is built on top of `aws-sdk` so you should set your AWS Region by changing `AWS_REGION` environment variable.
40
57
41
58
If you want to set it in JS code directly you can do it using `awsConfig` (see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html to see all available options) like
42
59
43
-
```
44
-
var worker = new StepFunctionWorker({
60
+
```javascript
61
+
constworker=newStepFunctionWorker({
45
62
activityArn :'<activity-ARN>',
46
63
workerName :'workerName',
47
64
fn : fn,
@@ -61,36 +78,114 @@ worker.close(function(){
61
78
})
62
79
```
63
80
81
+
#### Get info on current worker
82
+
83
+
```javascript
84
+
// A worker as multiple poolers and multiple running tasks
85
+
// You can have infos about it by doing
86
+
const {poolers, tasks} =worker.report();
87
+
88
+
// poolers is an array of {
89
+
// startTime: <Date>,
90
+
// workerName: <String>,
91
+
// status: <String>
92
+
// }
93
+
//
94
+
// tasks is an array of {
95
+
// taskToken: <String>,
96
+
// input: <Object>,
97
+
// startTime: <Date>
98
+
// }
99
+
//
100
+
```
101
+
102
+
#### Custom logging with winston
103
+
104
+
You can customize logging by using a [winston](https://www.npmjs.com/package/winston) logger (or winston-like logger) as input
105
+
106
+
```javascript
107
+
constwinston=require('winston');
108
+
109
+
constlogger=winston.createLogger({
110
+
level:'debug',
111
+
format:winston.format.json(),
112
+
defaultMeta: { service:'user-service' },
113
+
transports: [
114
+
//
115
+
// - Write to all logs with level `info` and below to `combined.log`
116
+
// - Write all logs error (and below) to `error.log`.
0 commit comments