bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

Fetching a job's parent job (traversing a flow tree starting from an intermediate node)

Open brncsk opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. I'm trying to traverse a flow from an intermediate node (e.g. one that has both a parent and children) in order to get a "state of the world" type of representation (e.g. all jobs in the flow, flattened, possibly represented as their names mapped to their errors or returnvalue or something else).

While traversing the tree downstream is possible by either invoking Job#getDependencies() or FlowProducer#getFlow(), it's less straightforward to fetch a Job instance representing the parent of a job, as parentKey.queueKey contains the fully qualified (i.e. prefixed by bull:) key of the queue which I cannot really do anything with.

Describe the solution you'd like I'd like a getter on Job that would return another Job instance representing its parent job, if exists.

Describe alternatives you've considered I implemented a utility function that effectively reverses QueueKeys#getQueueQualifiedName() thus returning the queue name from a qualified queue key by removing the prefix. This lets me use FlowProducer#getFlow() to fetch the parent job.

Additional context No additional context I'm aware of.

brncsk avatar Sep 12 '24 06:09 brncsk