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-hybrid...
[poolifier.git]
/
examples
/
typescript
/
worker.ts
diff --git
a/examples/typescript/worker.ts
b/examples/typescript/worker.ts
index ff75fb44f3b15707a7b27f76b00fa2937a8044ac..7ab1fc5649e0c0ec366a67225304e9fc9577e47e 100644
(file)
--- a/
examples/typescript/worker.ts
+++ b/
examples/typescript/worker.ts
@@
-1,27
+1,26
@@
import { ThreadWorker } from 'poolifier'
export interface MyData {
import { ThreadWorker } from 'poolifier'
export interface MyData {
- ok:
number
+ ok:
0 | 1
}
export interface MyResponse {
message: string
}
export interface MyResponse {
message: string
- data: MyData
+ data
?
: MyData
}
}
-class MyThreadWorker extends ThreadWorker<MyData,
Promise<MyResponse>
> {
+class MyThreadWorker extends ThreadWorker<MyData,
MyResponse
> {
constructor () {
constructor () {
- super(
data =>
this.process(data), {
+ super(
async (data?: MyData) => await
this.process(data), {
maxInactiveTime: 60000,
maxInactiveTime: 60000,
- async: true
})
}
})
}
- private async process (data: MyData): Promise<MyResponse> {
- return new Promise(resolve => {
+ private async process (data
?
: MyData): Promise<MyResponse> {
+ return
await
new Promise(resolve => {
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
- }, 10
_0
00)
+ }, 1000)
})
}
}
})
}
}