Skip to content

Commit

Permalink
fix: concurrency options for pool
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Oct 6, 2023
1 parent ba2c8b1 commit 88d56bf
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 73 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
"@golevelup/nestjs-rabbitmq": "^4.0.0",
"@golevelup/nestjs-stripe": "^0.6.3",
"@golevelup/nestjs-webhooks": "^0.2.16",
"@mikro-orm/core": "^5.8.6",
"@mikro-orm/migrations": "^5.8.6",
"@mikro-orm/core": "^5.8.7",
"@mikro-orm/migrations": "^5.8.7",
"@mikro-orm/nestjs": "^5.2.2",
"@mikro-orm/postgresql": "^5.8.6",
"@mikro-orm/reflection": "^5.8.6",
"@mikro-orm/postgresql": "^5.8.7",
"@mikro-orm/reflection": "^5.8.7",
"@mikro-orm/sql-highlighter": "^1.0.1",
"@nestjs/axios": "^3.0.0",
"@nestjs/cache-manager": "^2.1.0",
Expand Down Expand Up @@ -132,7 +132,7 @@
"rxjs": "^7.8.1",
"sharp": "^0.32.6",
"socket.io": "^4.7.2",
"stripe": "^13.8.0",
"stripe": "^13.9.0",
"swagger-stats": "^0.99.7",
"twilio": "4.18.1",
"unprofane": "^1.0.6",
Expand All @@ -142,8 +142,8 @@
"@firebase/app-compat": "^0.2.19",
"@firebase/app-types": "^0.9.0",
"@golevelup/ts-jest": "^0.4.0",
"@mikro-orm/cli": "^5.8.6",
"@mikro-orm/seeder": "^5.8.6",
"@mikro-orm/cli": "^5.8.7",
"@mikro-orm/seeder": "^5.8.7",
"@nestjs/cli": "10.1.18",
"@nestjs/schematics": "10.0.2",
"@nestjs/testing": "10.2.7",
Expand Down
130 changes: 65 additions & 65 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/common/misc/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const logger = new Logger("ThreadPool");

/* Creating a new thread pool with half of available threads and a maximum of available threads. */
export const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), path.resolve(__dirname, "workers.js"), {
enableTasksQueue: true,
tasksQueueOptions: {
concurrency: 8
},
errorHandler: error => logger.error(error),
onlineHandler: () => logger.log("✅ Worker is online"),
});
})

0 comments on commit 88d56bf

Please sign in to comment.