repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore: v2.5.0
[poolifier.git]
/
examples
/
typescript
/
worker.ts
diff --git
a/examples/typescript/worker.ts
b/examples/typescript/worker.ts
index 4b3c4e4520d15bce0cf6749973414d0afa063e57..adc8c4345ca1ead79eec6d31507e7fc07e53f7af 100644
(file)
--- a/
examples/typescript/worker.ts
+++ b/
examples/typescript/worker.ts
@@
-1,7
+1,7
@@
import { ThreadWorker } from 'poolifier'
export interface MyData {
import { ThreadWorker } from 'poolifier'
export interface MyData {
- ok:
number
+ ok:
0 | 1
}
export interface MyResponse {
}
export interface MyResponse {
@@
-11,17
+11,18
@@
export interface MyResponse {
class MyThreadWorker extends ThreadWorker<MyData, Promise<MyResponse>> {
constructor () {
class MyThreadWorker extends ThreadWorker<MyData, Promise<MyResponse>> {
constructor () {
- super(data => this.process(data), {
- maxInactiveTime: 60_000,
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
+ super((data: MyData) => this.process(data), {
+ maxInactiveTime: 60000,
async: true
})
}
private async process (data: MyData): Promise<MyResponse> {
async: true
})
}
private async process (data: MyData): Promise<MyResponse> {
- return new Promise(resolve => {
+ return
await
new Promise(resolve => {
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
- }, 10
_
000)
+ }, 10000)
})
}
}
})
}
}