Comparing version 1.18.1 to 1.18.2
@@ -152,2 +152,6 @@ /// <reference types="node" /> | ||
processedOn?: number; | ||
/** | ||
* Fully qualified key pointing to the parent of this job. | ||
*/ | ||
parentKey?: string; | ||
private toKey; | ||
@@ -154,0 +158,0 @@ private discarded; |
@@ -33,2 +33,6 @@ import { Redis } from 'ioredis'; | ||
processedOn?: number; | ||
/** | ||
* Fully qualified key pointing to the parent of this job. | ||
*/ | ||
parentKey?: string; | ||
private toKey; | ||
@@ -35,0 +39,0 @@ private discarded; |
@@ -70,2 +70,5 @@ "use strict"; | ||
} | ||
if (json.parentKey) { | ||
job.parentKey = json.parentKey; | ||
} | ||
return job; | ||
@@ -72,0 +75,0 @@ } |
@@ -0,1 +1,8 @@ | ||
## [1.18.2](https://github.com/taskforcesh/bullmq/compare/v1.18.1...v1.18.2) (2021-04-16) | ||
### Bug Fixes | ||
* add parentKey property to Job ([febc60d](https://github.com/taskforcesh/bullmq/commit/febc60dba94c29b85be3e1bc2547fa83ed932806)) | ||
## [1.18.1](https://github.com/taskforcesh/bullmq/compare/v1.18.0...v1.18.1) (2021-04-16) | ||
@@ -2,0 +9,0 @@ |
# Flows | ||
BullMQ supports parent - child relationships between jobs. The basic idea is that a parent job will only start to be processed when all its child jobs have been processed successfully. Apart from that, a parent or a child job are no different from regular jobs. | ||
{% page-ref page="parent-child-jobs.md" %} | ||
This functionality allows to create flows where jobs are the node of trees of arbitrary depth. | ||
{% hint style="info" %} | ||
Flows are a brand new feature in BullMQ, and although is implemented on a stable foundation there could be some unknown issues. | ||
{% endhint %} | ||
BullMQ supports parent - child relationships between jobs. The basic idea is that a parent job will not be moved to the wait status, i.e. can be picked up by a worker, until all its children jobs have been processed successfully. Apart from that, a parent or a child job are no different from regular jobs. | ||
This functionality enables the creation of flows where jobs are the node of trees of arbitrary depth. | ||
{% hint style="warning" %} | ||
Flows are added to a queue using the "Flow" class. | ||
Flows are added to a queue using the "FlowProducer" class. | ||
{% endhint %} | ||
@@ -27,7 +33,9 @@ | ||
```typescript | ||
import { Flow } from 'bullmq'; | ||
import { FlowProducer } from 'bullmq'; | ||
const flow = new Flow(); | ||
// A FlowProducer constructor takes an optional "connection" | ||
// object otherwise it connects to a local redis instance. | ||
const flowProducer = new FlowProducer(); | ||
const tree = await flow.add({ | ||
const flow = await flow.add({ | ||
name: 'renovate-interior', | ||
@@ -45,4 +53,8 @@ queueName: 'renovate', | ||
The above call will return instances for all the jobs added to the queue. Note that the parent queue does not need to be the same queue as the one used for the children. | ||
The above call will return instances for all the jobs added to the queue. | ||
{% hint style="info" %} | ||
Note that the parent queue does not need to be the same queue as the one used for the children. | ||
{% endhint %} | ||
When the parent job is processed it is possible to access the results generated by its child jobs. For example lets assume the following worker for the child jobs: | ||
@@ -64,3 +76,3 @@ | ||
we can implement a parent worker that sums the costs of the children's jobs using the "getChildrenValues" method. This method returns an object with job keys as keys and the result of that given job as a value: | ||
we can implement a parent worker that sums the costs of the children's jobs using the "_getChildrenValues_" method. This method returns an object with job keys as keys and the result of that given job as a value: | ||
@@ -84,4 +96,7 @@ ```typescript | ||
```typescript | ||
import { FlowProducer } from 'bullmq'; | ||
const flowProducer = new FlowProducer(); | ||
const queueName = 'assembly-line'; | ||
const chain = await flow.add({ | ||
const chain = await flowProducer.add({ | ||
name: 'car', | ||
@@ -101,5 +116,11 @@ data: { step: 'engine' }, | ||
In this case one job will be processed after the previous one has been completed. Note that the order of processing would be: 'chassis', 'wheels' and finally 'engine'. | ||
In this case one job will be processed after the previous one has been completed. | ||
{% hint style="info" %} | ||
the order of processing would be: 'chassis', 'wheels' and finally 'engine'. | ||
{% endhint %} | ||
#### Getters | ||
There are some special getters | ||
@@ -11,3 +11,3 @@ # API Reference | ||
| :--- | :--- | | ||
| [bullmq](https://github.com/taskforcesh/bullmq/tree/3a8873b6453405e6f8e57331f6cee30977406670/docs/gitbook/api/bullmq.md) | | | ||
| [bullmq](https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.md) | | | ||
# Flows | ||
{% hint style="warning" %} | ||
The following pattern, although still useful, has been mostly super-seeded by the new [Flows](../guide/jobs/flows.md) functionality | ||
{% endhint %} | ||
In some situations you need to execute a flow of actions that each and one of them could fail, it could be database updates, calls to external services, or any other kind of asynchronous call. | ||
@@ -4,0 +8,0 @@ |
@@ -26,3 +26,3 @@ # Table of contents | ||
* [Adding bulks](guide/jobs/adding-bulks.md) | ||
* [Flows](guide/jobs/parent-child-jobs.md) | ||
* [Flows](guide/jobs/flows.md) | ||
* [Stalled](guide/jobs/stalled.md) | ||
@@ -29,0 +29,0 @@ * [Getters](guide/jobs/getters.md) |
{ | ||
"name": "bullmq", | ||
"version": "1.18.1", | ||
"version": "1.18.2", | ||
"description": "Queue for messages and jobs based on Redis", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -38,2 +38,7 @@ import { Redis, Pipeline } from 'ioredis'; | ||
/** | ||
* Fully qualified key pointing to the parent of this job. | ||
*/ | ||
parentKey?: string; | ||
private toKey: (type: string) => string; | ||
@@ -138,2 +143,6 @@ | ||
if (json.parentKey) { | ||
job.parentKey = json.parentKey; | ||
} | ||
return job; | ||
@@ -140,0 +149,0 @@ } |
Sorry, the diff of this file is not supported yet
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
1342594
345
21530