Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.3.2
=====

* (improvement) Skip `task_manager_internals` queue when checking for sync-queues.



2.3.1
=====

Expand Down
5 changes: 3 additions & 2 deletions src/DependencyInjection/TaskManagerBundleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Torr\TaskManager\Config\BundleConfig;
use Torr\TaskManager\Log\LogCleaner;
use Torr\TaskManager\Task\DispatchAfterRunTask\DispatchAfterRunTask;
use Torr\TaskManager\Transport\TransportsHelper;

/**
* @final
Expand Down Expand Up @@ -49,12 +50,12 @@ public function prepend (ContainerBuilder $container) : void
// We only register the sync task, so that the own tasks are worked on right away
"messenger" => [
"transports" => [
"task_manager_internals" => [
TransportsHelper::INTERNAL_TRANSPORT_NAME => [
"dsn" => 'sync://',
],
],
"routing" => [
DispatchAfterRunTask::class => "task_manager_internals",
DispatchAfterRunTask::class => TransportsHelper::INTERNAL_TRANSPORT_NAME,
],
],
]);
Expand Down
3 changes: 2 additions & 1 deletion src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use Symfony\Component\Messenger\Attribute\AsMessage;
use Torr\TaskManager\Task\Task;
use Torr\TaskManager\Task\TaskMetaData;
use Torr\TaskManager\Transport\TransportsHelper;

/**
* This task takes another task and puts it into the queue.
*
* This task is supposed to be worked on synchronously, as it is pretty lightweight and only
* redispatches the given task.
*/
#[AsMessage(transport: "task_manager_internals")]
#[AsMessage(transport: TransportsHelper::INTERNAL_TRANSPORT_NAME)]
readonly class DispatchAfterRunTask extends Task
{
public function __construct (
Expand Down
9 changes: 8 additions & 1 deletion src/Transport/TransportsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
final readonly class TransportsHelper
{
public const string INTERNAL_TRANSPORT_NAME = "task_manager_internals";

/**
*/
public function __construct (
Expand All @@ -29,8 +31,13 @@ public function __construct (
*/
public function hasSyncTransport () : bool
{
foreach ($this->getAllTransports() as $transport)
foreach ($this->getAllTransports() as $name => $transport)
{
if (self::INTERNAL_TRANSPORT_NAME === $name)
{
continue;
}

if ($transport instanceof SyncTransport)
{
return true;
Expand Down