+// ---------------------------------------------------------------------------
+
+let parallelHTTPBroadcastWorker: Piscina
+
+function parallelHTTPBroadcastFromWorker (options: Parameters<typeof httpBroadcast>[0]): Promise<ReturnType<typeof httpBroadcast>> {
+ if (!parallelHTTPBroadcastWorker) {
+ parallelHTTPBroadcastWorker = new Piscina({
+ filename: join(__dirname, 'workers', 'http-broadcast.js'),
+ // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs
+ concurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast-parallel'],
+ maxThreads: 1
+ })
+ }
+
+ return parallelHTTPBroadcastWorker.run(options)
+}
+
+// ---------------------------------------------------------------------------
+
+let sequentialHTTPBroadcastWorker: Piscina
+
+function sequentialHTTPBroadcastFromWorker (options: Parameters<typeof httpBroadcast>[0]): Promise<ReturnType<typeof httpBroadcast>> {
+ if (!sequentialHTTPBroadcastWorker) {
+ sequentialHTTPBroadcastWorker = new Piscina({
+ filename: join(__dirname, 'workers', 'http-broadcast.js'),
+ // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs
+ concurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast'],
+ maxThreads: 1
+ })
+ }
+
+ return sequentialHTTPBroadcastWorker.run(options)
+}
+