54bb7461f6fa5cafb2cb04270ce732b093d8ce53
1 import type { Worker
as ClusterWorker
} from
'node:cluster'
2 import type { MessagePort
} from
'node:worker_threads'
3 import type { KillBehavior
} from
'./worker/worker-options'
6 * Make all properties in T non-readonly.
8 export type Draft
<T
> = { -readonly [P
in keyof T
]?: T
[P
] }
11 * Message object that is passed between worker and main worker.
13 export interface MessageValue
<
15 MainWorker
extends ClusterWorker
| MessagePort
| unknown
= unknown
18 * Input data that will be passed to the worker.
28 readonly kill
?: KillBehavior
| 1
32 readonly error
?: string
36 readonly taskRunTime
?: number
38 * Reference to main worker.
40 * Only for internal use.
42 readonly parent?: MainWorker
46 * An object holding the execution response promise resolve/reject callbacks.
48 * @typeParam Response - Type of execution response. This can only be serializable data.
50 export interface PromiseResponseWrapper
<Response
= unknown
> {
52 * Resolve callback to fulfill the promise.
54 readonly resolve
: (value
: Response
) => void
56 * Reject callback to reject the promise.
58 readonly reject
: (reason
?: string) => void
60 * The worker handling the promise key .
62 readonly workerKey
: number