Comparing version 0.0.15 to 0.0.16
14
index.js
@@ -36,2 +36,6 @@ const { Worker } = require('worker_threads'); | ||
defaultExtension: 'js', | ||
// default worker options to pass to `new Worker` | ||
// (can be overriden on a per job basis) | ||
// <https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options> | ||
worker: {}, | ||
...config | ||
@@ -395,3 +399,11 @@ }; | ||
this.workers[name] = new Worker(job.path, { | ||
workerData: { job } | ||
...(this.config.worker ? this.config.worker : {}), | ||
...(job.worker ? job.worker : {}), | ||
workerData: { | ||
job, | ||
...(this.config.worker && this.config.worker.workerData | ||
? this.config.worker.workerData | ||
: {}), | ||
...(job.worker && job.worker.workerData ? job.worker.workerData : {}) | ||
} | ||
}); | ||
@@ -398,0 +410,0 @@ debug('worker started', name); |
{ | ||
"name": "bree", | ||
"description": "The best job scheduler for Node.js with support for cron, ms, and human-friendly strings. Uses workers and spawns sandboxed processes. Supports async/await, retries, throttling, concurrency, and cancelable promises (graceful shutdown). Simple, fast, and the most lightweight tool for the job. Made for Lad.", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
@@ -25,2 +25,3 @@ # [**bree**](https://github.com/breejs/bree) | ||
* [Complex timeouts and intervals](#complex-timeouts-and-intervals) | ||
* [Custom Worker Options](#custom-worker-options) | ||
* [Concurrency](#concurrency) | ||
@@ -105,3 +106,4 @@ * [Real-world usage](#real-world-usage) | ||
{ | ||
name: 'foo-bar' | ||
name: 'foo-bar', | ||
timeout: 0 | ||
}, | ||
@@ -111,4 +113,5 @@ | ||
{ | ||
name: 'beep', | ||
path: path.join(__dirname, 'jobs', 'some-other-path') | ||
name: 'beep', | ||
path: path.join(__dirname, 'jobs', 'some-other-path'), | ||
timeout: 0 | ||
}, | ||
@@ -203,2 +206,15 @@ | ||
interval: '2m' | ||
}, | ||
// runs `./jobs/worker-14.js` on start with custom `new Worker` options (see below) | ||
{ | ||
name: 'worker-14', | ||
timeout: 0, | ||
// <https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options> | ||
worker: { | ||
workerData: { | ||
foo: 'bar', | ||
beep: 'boop' | ||
} | ||
} | ||
} | ||
@@ -332,2 +348,13 @@ ] | ||
## Custom Worker Options | ||
You can pass a default worker configuration object as `new Bree({ worker: { ... } });`. | ||
These options are passed to the `options` argument when we internally invoke `new Worker(path, options)`. | ||
Additionally, you can pass custom worker options on a per-job basis through a `worker` property Object on the job definition. | ||
See complete documentation here for options <https://nodejs.org/api/worker_threads.html#worker_thre> (but you usually don't have to modify these). | ||
## Concurrency | ||
@@ -334,0 +361,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44723
612
447