From 3a38a471cbeda70ac9d4d9744b199090dc6f0a12 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Thu, 11 Jan 2024 19:56:44 -0500 Subject: [PATCH] docs(sandbox): add URL support section (#2373) ref #2326 #2372 --- .../guide/workers/sandboxed-processors.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/gitbook/guide/workers/sandboxed-processors.md b/docs/gitbook/guide/workers/sandboxed-processors.md index a9c904027f..9cfc16d71c 100644 --- a/docs/gitbook/guide/workers/sandboxed-processors.md +++ b/docs/gitbook/guide/workers/sandboxed-processors.md @@ -31,6 +31,22 @@ worker = new Worker(queueName, processorFile); A tutorial with code examples on how to use sandboxed processors using Typescript can be found [here](https://blog.taskforce.sh/using-typescript-with-bullmq/). +### URL Support + +Processors can be defined using URL instances: + +```typescript +import { pathToFileURL } from 'url'; + +const processorUrl = pathToFileURL(__dirname + '/my_procesor.js'); + +worker = new Worker(queueName, processorUrl); +``` + +{% hint style="warning" %} +Recommended for Windows OS. +{% endhint %} + ### Worker Threads The default mechanism for launching sandboxed workers is using Node's spawn process library. From BullMQ version v3.13.0, it is also possible to launch the workers using Node's new Worker Threads library. These threads are supposed to be less resource-demanding than the previous approach, however, they are still not as lightweight as we could expect since Node's runtime needs to be duplicated by every thread. @@ -44,5 +60,6 @@ const processorFile = path.join(__dirname, 'my_procesor.js'); worker = new Worker(queueName, processorFile, { useWorkerThreads: true }); ``` +## Read more: - +* 💡 [Worker API Reference](https://api.docs.bullmq.io/classes/v5.Worker.html)