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-cluster...
[poolifier.git]
/
examples
/
typescript
/
http-server-pool
/
fastify-hybrid
/
src
/
fastify-worker.ts
diff --git
a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
index dd77f1238a90a203185f1fe2a9ae4b803d378e5f..388730dcec9bda04a13315f4f0b5fb1814981266 100644
(file)
--- a/
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
+++ b/
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
@@
-13,17
+13,21
@@
ClusterWorkerResponse
private static readonly startFastify = async (
workerData?: ClusterWorkerData
): Promise<ClusterWorkerResponse> => {
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
})
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 (
FastifyWorker.fastify.all('/api/echo', async request => {
return (
- await FastifyWorker.fastify.execute({
body
: request.body }, 'echo')
- ).
body
+ await FastifyWorker.fastify.execute({
data
: request.body }, 'echo')
+ ).
data
})
FastifyWorker.fastify.get<{
})
FastifyWorker.fastify.get<{
@@
-31,19
+35,24
@@
ClusterWorkerResponse
}>('/api/factorial/:number', async request => {
const { number } = request.params
return (
}>('/api/factorial/:number', async request => {
const { number } = request.params
return (
- await FastifyWorker.fastify.execute({
body
: { number } }, 'factorial')
- ).
body
+ await FastifyWorker.fastify.execute({
data
: { number } }, 'factorial')
+ ).
data
})
await FastifyWorker.fastify.listen({ port })
return {
status: true,
})
await FastifyWorker.fastify.listen({ port })
return {
status: true,
- port: (FastifyWorker.fastify.server.address() as AddressInfo).port
+ port: (FastifyWorker.fastify.server.address() as AddressInfo)
?
.port
}
}
public constructor () {
}
}
public constructor () {
- super(FastifyWorker.startFastify)
+ super(FastifyWorker.startFastify, {
+ killHandler: async () => {
+ await FastifyWorker.fastify.pool.destroy()
+ await FastifyWorker.fastify.close()
+ }
+ })
}
}
}
}