fix: refine type definition for transferList
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 22 Apr 2024 14:12:32 +0000 (16:12 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 22 Apr 2024 14:12:32 +0000 (16:12 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts
examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts
examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts
src/pools/abstract-pool.ts
src/pools/pool.ts
src/pools/thread/fixed.ts
src/utility-types.ts

index e1a64b1559ca4e9d8dc91ba424f08d0f08299863..018cac59cf6762769e0cc713b687a2463832718f 100644 (file)
@@ -14,7 +14,7 @@ declare module 'fastify' {
     execute: (
       data?: ThreadWorkerData,
       name?: string,
-      transferList?: TransferListItem[]
+      transferList?: readonly TransferListItem[]
     ) => Promise<ThreadWorkerResponse>
   }
 }
index 79d24dc61fe0a3f47a25d4e5fb5ddeb5880e2a2a..f105d7af3a10395421b118e3ec308445ea0a63a4 100644 (file)
@@ -38,7 +38,7 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
       async (
         data?: ThreadWorkerData,
         name?: string,
-        transferList?: TransferListItem[]
+        transferList?: readonly TransferListItem[]
       ): Promise<ThreadWorkerResponse> =>
         await pool.execute(data, name, transferList)
     )
index 73f8b0715963679fe64a722fae3bbecd5042cdac..899aa1a028926166853cb383eaf8b2dc7cdebf46 100644 (file)
@@ -11,7 +11,7 @@ declare module 'fastify' {
     execute: (
       data?: WorkerData,
       name?: string,
-      transferList?: TransferListItem[]
+      transferList?: readonly TransferListItem[]
     ) => Promise<WorkerResponse>
   }
 }
index 766ef44ec3fdcbb5e1e11304340d8065d47e03c1..450a2aeaf2c7fda086aa19d117c5af5c20636ed2 100644 (file)
@@ -38,7 +38,7 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
       async (
         data?: WorkerData,
         name?: string,
-        transferList?: TransferListItem[]
+        transferList?: readonly TransferListItem[]
       ): Promise<WorkerResponse> => await pool.execute(data, name, transferList)
     )
   }
index b5e528ec643bb7d58325ab46d49f82c64f0f442b..01e621c297a1bc0cb818b807d1e13fe33344952e 100644 (file)
@@ -893,7 +893,7 @@ export abstract class AbstractPool<
   public async execute (
     data?: Data,
     name?: string,
-    transferList?: TransferListItem[]
+    transferList?: readonly TransferListItem[]
   ): Promise<Response> {
     return await new Promise<Response>((resolve, reject) => {
       if (!this.started) {
@@ -1228,7 +1228,7 @@ export abstract class AbstractPool<
   protected abstract sendToWorker (
     workerNodeKey: number,
     message: MessageValue<Data>,
-    transferList?: TransferListItem[]
+    transferList?: readonly TransferListItem[]
   ): void
 
   /**
index d7b6eeabeb074c31103854ec2f9789d137ff8409..bcf7d9385035b938ac3c0ed9bdb24dda6382e0a1 100644 (file)
@@ -282,7 +282,7 @@ export interface IPool<
   readonly execute: (
     data?: Data,
     name?: string,
-    transferList?: TransferListItem[]
+    transferList?: readonly TransferListItem[]
   ) => Promise<Response>
   /**
    * Starts the minimum number of workers in this pool.
index 78912c2b03d11537bebce5cc0576d058157321af..7977cd61abd5263023b855fe9f7f23ba5135de10 100644 (file)
@@ -51,7 +51,7 @@ export class FixedThreadPool<
   protected sendToWorker (
     workerNodeKey: number,
     message: MessageValue<Data>,
-    transferList?: TransferListItem[]
+    transferList?: readonly TransferListItem[]
   ): void {
     this.workerNodes[workerNodeKey]?.messageChannel?.port1.postMessage(
       {
index c7663606cf86afe67f84d6f25d831d567b5bab3f..b3cea1a1516004b18b757333b71853c3faa35f8b 100644 (file)
@@ -82,7 +82,7 @@ export interface Task<Data = unknown> {
   /**
    * Array of transferable objects.
    */
-  readonly transferList?: TransferListItem[]
+  readonly transferList?: readonly TransferListItem[]
   /**
    * Timestamp.
    */