X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=0723b4395407a94b18d3cafcfc6e5db2360017e0;hb=2826fc7a3ba7197b08fe5c352d8965b234f3abc5;hp=fa1c0ffefdf27e6996789cc444f44d81de9076fc;hpb=67e8ef11907ab8ae70740d7c9f4d5d225ed8d522;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index fa1c0ffe..0723b439 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -1,6 +1,6 @@ import type { EventLoopUtilization } from 'node:perf_hooks' import type { KillBehavior } from './worker/worker-options' -import type { IWorker, Task } from './pools/worker' +import type { IWorker } from './pools/worker' /** * Task error. @@ -56,6 +56,35 @@ export interface WorkerStatistics { elu: boolean } +/** + * Message object that is passed as a task between main worker and worker. + * + * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data. + * @internal + */ +export interface Task { + /** + * Worker id. + */ + readonly workerId: number + /** + * Task name. + */ + readonly name?: string + /** + * Task input data that will be passed to the worker. + */ + readonly data?: Data + /** + * Timestamp. + */ + readonly timestamp?: number + /** + * Message UUID. + */ + readonly id?: string +} + /** * Message object that is passed between main worker and worker. * @@ -86,9 +115,9 @@ export interface MessageValue */ readonly ready?: boolean /** - * Whether the worker starts or stops its aliveness check. + * Whether the worker starts or stops its activity check. */ - readonly checkAlive?: boolean + readonly checkActive?: boolean } /** @@ -105,11 +134,11 @@ export interface PromiseResponseWrapper< /** * Resolve callback to fulfill the promise. */ - readonly resolve: (value: Response) => void + readonly resolve: (value: Response | PromiseLike) => void /** * Reject callback to reject the promise. */ - readonly reject: (reason?: string) => void + readonly reject: (reason?: unknown) => void /** * The worker handling the execution. */