private static readonly startExpress = (
workerData?: ClusterWorkerData
): ClusterWorkerResponse => {
- const { port, workerFile, minWorkers, maxWorkers } =
+ const { port, workerFile, minWorkers, maxWorkers, ...poolOptions } =
workerData as ClusterWorkerData
ExpressWorker.requestHandlerPool = new DynamicThreadPool<
minWorkers ?? 1,
maxWorkers ?? availableParallelism(),
workerFile,
- workerData
+ poolOptions
)
const application: Express = express()
private static readonly startFastify = async (
workerData?: ClusterWorkerData
): Promise<ClusterWorkerResponse> => {
- const { port } = workerData as ClusterWorkerData
+ const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData
FastifyWorker.fastify = Fastify({
logger: true
})
- await FastifyWorker.fastify.register(fastifyPoolifier, workerData)
+ await FastifyWorker.fastify.register(
+ fastifyPoolifier,
+ fastifyPoolifierOptions
+ )
FastifyWorker.fastify.all('/api/echo', async (request) => {
return (
private static readonly startWebSocketServer = (
workerData?: ClusterWorkerData
): ClusterWorkerResponse => {
- const { port, workerFile, minWorkers, maxWorkers } =
+ const { port, workerFile, minWorkers, maxWorkers, ...poolOptions } =
workerData as ClusterWorkerData
WebSocketServerWorker.requestHandlerPool = new DynamicThreadPool<
minWorkers ?? 1,
maxWorkers ?? availableParallelism(),
workerFile,
- workerData
+ poolOptions
)
WebSocketServerWorker.wss = new WebSocketServer({ port }, () => {