X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=ec5ff44d861baeff4b0779a83e19f2b869ee560b;hb=7cf00f70a6dffca3af737ea9193a6c3be69ac0b7;hp=54bb7461f6fa5cafb2cb04270ce732b093d8ce53;hpb=2740a743fcbf64e0ee674530e3cbcf6df710c1ef;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index 54bb7461..ec5ff44d 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -1,6 +1,7 @@ import type { Worker as ClusterWorker } from 'node:cluster' import type { MessagePort } from 'node:worker_threads' import type { KillBehavior } from './worker/worker-options' +import type { IPoolWorker } from './pools/pool-worker' /** * Make all properties in T non-readonly. @@ -45,9 +46,13 @@ export interface MessageValue< /** * An object holding the execution response promise resolve/reject callbacks. * + * @typeParam Worker - Type of worker. * @typeParam Response - Type of execution response. This can only be serializable data. */ -export interface PromiseResponseWrapper { +export interface PromiseResponseWrapper< + Worker extends IPoolWorker, + Response = unknown +> { /** * Resolve callback to fulfill the promise. */ @@ -57,7 +62,7 @@ export interface PromiseResponseWrapper { */ readonly reject: (reason?: string) => void /** - * The worker handling the promise key . + * The worker handling the promise. */ - readonly workerKey: number + readonly worker: Worker }