X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futility-types.ts;h=28bf19e256abaef2f619051773ad55456643b842;hb=85003dff831b309b12d624215a8d67634af82b50;hp=a8da491e16fe62143d1d716672c4b4db44aa8e9f;hpb=21f710aa73abbb5d90328cfb199adfc0f7a70406;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index a8da491e..28bf19e2 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. @@ -8,12 +8,16 @@ import type { IWorker, Task } from './pools/worker' * @typeParam Data - Type of data sent to the worker triggering an error. This can only be structured-cloneable data. */ export interface TaskError { + /** + * Task name triggering the error. + */ + readonly name: string /** * Error message. */ readonly message: string /** - * Data passed to the worker triggering the error. + * Data triggering the error. */ readonly data?: Data } @@ -24,6 +28,10 @@ export interface TaskError { * @internal */ export interface TaskPerformance { + /** + * Task name. + */ + readonly name: string /** * Task performance timestamp. */ @@ -48,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. *