Skip to content

Commit

Permalink
docs(sandbox): add URL support section (#2373) ref #2326 #2372
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Jan 12, 2024
1 parent 0a70f4c commit 3a38a47
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/gitbook/guide/workers/sandboxed-processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

0 comments on commit 3a38a47

Please sign in to comment.