Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sandbox): add getChildrenValues method #2600

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anirudh1713
Copy link

@anirudh1713 anirudh1713 commented Jun 9, 2024

right before starting a child, get and pass children values along side other job data. This should be okay as the parent job runs only after all children have finished. We then use this data to implement getChildrenValues function for sanboxed jobs.

"fix #1306", "fix #753".

Please let me know if there are other better approaches if this doesn't fit the needs of bullmq. I came up with this solution based on whatever little context I could get from the codebase so some choices may be wrong.
If this approach is acceptable, we can do the same for getFailedChildrenValues, getDependencies and getDependenciesCount

Thanks for taking a look at this PR.

right before starting a child, get and pass children values along side other job data. This should
be okay as the parent job runs only after all children have finished. We then use this data to
implement `getChildrenValues` function for sanboxed jobs.

"fix  taskforcesh#1306", "fix taskforcesh#753".
Comment on lines +15 to +18
const childrenValues = await job.getChildrenValues();
await child.send({
cmd: ChildCommand.Start,
job: job.asJSONSandbox(),
job: { ...job.asJSONSandbox(), childrenValues },
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ok, considering parent only starts after all of its children are done. Also, ig its probably ok to assume that children values don't need to be serialized. 🤔

If bullmq ever introduces new functionalities around running parent job before child jobs finishes, this approach will probably produce unexpected behavior since it will only return this last known values (based on when it was started).

@roggervalf
Copy link
Collaborator

hi @anirudh1713 sorry for the delay. Actually there is one use case where you can create children dynamically https://docs.bullmq.io/patterns/process-step-jobs#waiting-children. If waiting for children step returns false right away in the same first execution of the parent, children values won't be available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants