lucid
lucid copied to clipboard
Fix/v10.x
In Laravel 10.x, the flow of dispatch helper function changed a bit and lucid wont be working on it anymore. To solve it, let me create this PR.
- run method of Lucid\Bus\UnitDispatcher.php &
- serve method of Lucid\Bus\ServesFeature.php
will now be using dispatchSync() not the dispatch() that lucid used previously.
@NayThuKhant Great job. Problem with the PR is that dispatchSync will always perform the job/feature synchronously. One of the Lucid features is that jobs/features can be dispatched for delayed/async processing. Laravel does not return the result anymore after a dispatch but it could be an improvement to choose between sync/async. The consequence of async dispatch is that the result cannot be used, but that is the way async works.
@NayThuKhant Great job. Problem with the PR is that dispatchSync will always perform the job/feature synchronously. One of the Lucid features is that jobs/features can be dispatched for delayed/async processing. Laravel does not return the result anymore after a dispatch but it could be an improvement to choose between sync/async. The consequence of async dispatch is that the result cannot be used, but that is the way async works.
I think we can still use runInQueue if only we want to run a job synchronously, isn't it?
public function runInQueue($unit, array $arguments = [], $queue = 'default')
{
// instantiate and queue the unit
$reflection = new ReflectionClass($unit);
$instance = $reflection->newInstanceArgs($arguments);
$instance->onQueue((string)$queue);
return $this->dispatch($instance);
}
Hello again, Any chance a contributor to revive this project. It is an important library. If no feature are added, at least keep up to date with the iteration of Laravel version.
@NayThuKhant We're running into a similar issue with the (https://github.com/ksimenic/lucid) fork because of the dispatchSync
change.
The difficulty with having to use the runInQueue
method is that you need to know the queue name to dispatch your job or operation to.
We use separate queues that are configured in the global queue configuration, thus resulting in jobs being sent to the wrong queue. (basically any queue that is named different than default will go wrong)
In the old situation, they would be dispatched to the correct queue (as configured in the laravel queue config)