repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-cluster...
[poolifier.git]
/
examples
/
typescript
/
websocket-server-pool
/
ws-cluster
/
src
/
worker.ts
diff --git
a/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts
b/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts
index 5e758eb7d3f845e1d8508bf907bda9fa7fcbcc3d..0e8dc20a95fd8d2f3f161381d07f90a36e60b933 100644
(file)
--- a/
examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts
+++ b/
examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts
@@
-8,16
+8,16
@@
import {
type WorkerResponse
} from './types.js'
type WorkerResponse
} from './types.js'
-const factorial: (n: number) => number = n => {
- if (n === 0) {
- return 1
- }
- return factorial(n - 1) * n
-}
-
class WebSocketServerWorker extends ClusterWorker<WorkerData, WorkerResponse> {
private static wss: WebSocketServer
class WebSocketServerWorker extends ClusterWorker<WorkerData, WorkerResponse> {
private static wss: WebSocketServer
+ private static readonly factorial = (n: number): number => {
+ if (n === 0) {
+ return 1
+ }
+ return WebSocketServerWorker.factorial(n - 1) * n
+ }
+
private static readonly startWebSocketServer = (
workerData?: WorkerData
): WorkerResponse => {
private static readonly startWebSocketServer = (
workerData?: WorkerData
): WorkerResponse => {
@@
-49,7
+49,9
@@
class WebSocketServerWorker extends ClusterWorker<WorkerData, WorkerResponse> {
ws.send(
JSON.stringify({
type: MessageType.factorial,
ws.send(
JSON.stringify({
type: MessageType.factorial,
- data: { number: factorial(data.number as number) }
+ data: {
+ number: WebSocketServerWorker.factorial(data.number as number)
+ }
})
)
break
})
)
break