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/express-worker_thr...
[poolifier.git]
/
examples
/
typescript
/
http-server-pool
/
fastify-hybrid
/
src
/
request-handler-worker.ts
diff --git
a/examples/typescript/http-server-pool/fastify-hybrid/src/request-handler-worker.ts
b/examples/typescript/http-server-pool/fastify-hybrid/src/request-handler-worker.ts
index d3b6c876048afed0392a707f4bae618e7f4e6048..8c247819488b5548f3e4fe1adbbaf106286cd3f4 100644
(file)
--- a/
examples/typescript/http-server-pool/fastify-hybrid/src/request-handler-worker.ts
+++ b/
examples/typescript/http-server-pool/fastify-hybrid/src/request-handler-worker.ts
@@
-1,21
+1,21
@@
import { ThreadWorker } from 'poolifier'
import {
import { ThreadWorker } from 'poolifier'
import {
- type
Body
Payload,
+ type
Data
Payload,
type ThreadWorkerData,
type ThreadWorkerResponse
} from './types.js'
type ThreadWorkerData,
type ThreadWorkerResponse
} from './types.js'
-const factorial: (n: number) => number = (n) => {
- if (n === 0) {
- return 1
- }
- return factorial(n - 1) * n
-}
-
class RequestHandlerWorker<
class RequestHandlerWorker<
- Data extends ThreadWorkerData<
Body
Payload>,
- Response extends ThreadWorkerResponse<
Body
Payload>
+ Data extends ThreadWorkerData<
Data
Payload>,
+ Response extends ThreadWorkerResponse<
Data
Payload>
> extends ThreadWorker<Data, Response> {
> extends ThreadWorker<Data, Response> {
+ private static readonly factorial = (n: number): number => {
+ if (n === 0) {
+ return 1
+ }
+ return RequestHandlerWorker.factorial(n - 1) * n
+ }
+
public constructor () {
super({
echo: (workerData?: Data) => {
public constructor () {
super({
echo: (workerData?: Data) => {
@@
-23,7
+23,11
@@
class RequestHandlerWorker<
},
factorial: (workerData?: Data) => {
return {
},
factorial: (workerData?: Data) => {
return {
- body: { number: factorial(workerData?.body?.number as number) }
+ data: {
+ number: RequestHandlerWorker.factorial(
+ workerData?.data?.number as number
+ )
+ }
} as unknown as Response
}
})
} as unknown as Response
}
})
@@
-31,6
+35,6
@@
class RequestHandlerWorker<
}
export const requestHandlerWorker = new RequestHandlerWorker<
}
export const requestHandlerWorker = new RequestHandlerWorker<
-ThreadWorkerData<
Body
Payload>,
-ThreadWorkerResponse<
Body
Payload>
+ThreadWorkerData<
Data
Payload>,
+ThreadWorkerResponse<
Data
Payload>
>()
>()