Skip to content

Conversation

sebestenyb
Copy link

#57402

The Illuminate\Bus\Dispatcher class initiate the PendingBatch and PendingChain instances directly, instead of using the container to resolve them.

This makes impossible to extend and swap these classes.

Practical example:

  • Having a multi-tenanted application, where each tenant has it's own queue (to mitigate noisy neighbour problem).
  • It is possible to define a dynamic, tenant-aware queue for individual jobs, it is not easily possible to do for batches and chains.
  • The developer has to specify the ->onQueue() modifier for every instance of batches and chains, which can be unnecessarily verbose.
  • If the framework would let the developer to re-bind the PendingBatch and/or PendingChain instances, the dynamic queue resolution could be easily done in one place - inside the tenant aware
    descendant class.

$jobs = ChainedBatch::prepareNestedBatches($jobs);

return new PendingChain($jobs->shift(), $jobs->toArray());
return $this->container->make(PendingChain::class, [$jobs->shift(), $jobs->toArray()]);

Choose a reason for hiding this comment

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

The parameters need to be associative array in Laravel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants