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
Copy file name to clipboardExpand all lines: packages/promise-pool.md
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,25 @@ const pool = PromisePool
67
67
The default concurrency is `10`.
68
68
69
69
70
+
#### Adjust the Concurrency of a Running Pool
71
+
-*Added in `2.3.0`*
72
+
73
+
You can adjust the concurrency while processing tasks. You may use the `pool.useConcurrency(<num>)` method to increase or decrease the previously configured concurrency of a promise pool instance.
74
+
75
+
```js
76
+
constpool= PromisePool
77
+
.for(users)
78
+
.withConcurrency(10)
79
+
.process(async (user, index, pool) => {
80
+
if (condition) {
81
+
pool.useConcurrency(200)
82
+
}
83
+
84
+
awaitUser.createIfNotExisting(user)
85
+
})
86
+
```
87
+
88
+
70
89
### Start Processing
71
90
The `process` method should be the last call in your method chain because it starts the promise pool processing. The `process` method accepts an async callback (function) defining the processing for each item:
0 commit comments