refactor: cleanup http client example
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 11 Aug 2023 19:57:39 +0000 (21:57 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 11 Aug 2023 19:57:39 +0000 (21:57 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
examples/typescript/http-client-pool/src/main.ts

index 1f4532c9a0147d7a30e443724c6851bbb52bd412..f307bb622ca7e5dbe549be2fffe33991e0caa547 100644 (file)
@@ -2,12 +2,12 @@ import { availableParallelism } from 'poolifier'
 import { httpClientPool } from './pool.js'
 import { type WorkerResponse } from './types.js'
 
-const parallelism = availableParallelism()
+const parallelism = availableParallelism() * 2
 const requestUrl = 'http://localhost:8080/'
 
 for (const workerFunction of ['node_fetch', 'fetch', 'axios']) {
   const httpClientPoolPromises = new Set<Promise<WorkerResponse>>()
-  for (let i = 0; i < availableParallelism(); i++) {
+  for (let i = 0; i < parallelism; i++) {
     httpClientPoolPromises.add(
       httpClientPool.execute({ input: requestUrl }, workerFunction)
     )