X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=57ff000330e29cc7dffb3541a65438c3edf65b80;hb=cdb517b318cd4f26b4895988ae8444d50945ddde;hp=9cdf6b0a7e82f9d1e3da5fb434537ca8e2d943f9;hpb=a788de39a01b042deb0707c2e92af99181b933d2;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index 9cdf6b0a..57ff0003 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -11,6 +11,44 @@ import type { IWorker, Task } from './pools/worker' */ export type Draft = { -readonly [P in keyof T]?: T[P] } +/** + * Task error. + * + * @typeParam Data - Type of data sent to the worker. This can only be serializable data. + */ +export interface TaskError { + /** + * Error message. + */ + message: string + /** + * Data passed to the worker triggering the error. + */ + data?: Data +} + +/** + * Task performance. + */ +export interface TaskPerformance { + /** + * Task performance timestamp. + */ + timestamp: number + /** + * Task runtime. + */ + runTime?: number + /** + * Task wait time. + */ + waitTime?: number + /** + * Task event loop utilization. + */ + elu?: EventLoopUtilization +} + /** * Performance statistics computation. */ @@ -23,14 +61,16 @@ export interface WorkerStatistics { /** * Message object that is passed between main worker and worker. * + * @typeParam MessageData - Type of data sent to and/or from the worker. This can only be serializable data. * @typeParam Data - Type of data sent to the worker. This can only be serializable data. * @typeParam MainWorker - Type of main worker. * @internal */ export interface MessageValue< + MessageData = unknown, Data = unknown, MainWorker extends ClusterWorker | MessagePort = ClusterWorker | MessagePort -> extends Task { +> extends Task { /** * Kill code. */ @@ -38,23 +78,11 @@ export interface MessageValue< /** * Task error. */ - readonly error?: string - /** - * Task data triggering task error. - */ - readonly errorData?: unknown - /** - * Runtime. - */ - readonly runTime?: number - /** - * Wait time. - */ - readonly waitTime?: number + readonly taskError?: TaskError /** - * Event loop utilization. + * Task performance. */ - readonly elu?: EventLoopUtilization + readonly taskPerformance?: TaskPerformance /** * Reference to main worker. */