diff --git a/CHANGELOG.md b/CHANGELOG.md index b510498..570be9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +2.3.1 +===== + +* (bug) Properly handle `DispatchAfterRunTask`. +* (improvement) Add `task_manager_internals` transport for internal messages. + + 2.3.0 ===== diff --git a/src/DependencyInjection/TaskManagerBundleExtension.php b/src/DependencyInjection/TaskManagerBundleExtension.php new file mode 100644 index 0000000..477eac7 --- /dev/null +++ b/src/DependencyInjection/TaskManagerBundleExtension.php @@ -0,0 +1,62 @@ +processConfiguration(new TaskManagerBundleConfiguration(), $configs); + + $container->getDefinition(BundleConfig::class) + ->setArgument('$sortedQueues', $config["queues"]); + + // if the new value was customized, use it. Otherwise keep using + // the old value. If none is set, they use the same default, so everything + // is fine. + $logTtl = 28 !== $config["log"]["ttl"] + ? $config["log"]["ttl"] + : $config["log_ttl"]; + + $container->getDefinition(LogCleaner::class) + ->setArgument('$logTtlInDays', $logTtl) + ->setArgument('$logMaxEntries', $config["log"]["max_entries"]); + } + + /** + * + */ + #[\Override] + public function prepend (ContainerBuilder $container) : void + { + $container->prependExtensionConfig("framework", [ + // We only register the sync task, so that the own tasks are worked on right away + "messenger" => [ + "transports" => [ + "task_manager_internals" => [ + "dsn" => 'sync://', + ], + ], + "routing" => [ + DispatchAfterRunTask::class => "task_manager_internals", + ], + ], + ]); + } +} diff --git a/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php b/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php index 7e57d28..8da53dd 100644 --- a/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php +++ b/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php @@ -2,6 +2,7 @@ namespace Torr\TaskManager\Task\DispatchAfterRunTask; +use Symfony\Component\Messenger\Attribute\AsMessage; use Torr\TaskManager\Task\Task; use Torr\TaskManager\Task\TaskMetaData; @@ -11,6 +12,7 @@ * 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")] readonly class DispatchAfterRunTask extends Task { public function __construct ( diff --git a/src/TaskManagerBundle.php b/src/TaskManagerBundle.php index 51833d2..190d4d9 100644 --- a/src/TaskManagerBundle.php +++ b/src/TaskManagerBundle.php @@ -5,12 +5,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; -use Torr\BundleHelpers\Bundle\ConfigurableBundleExtension; -use Torr\TaskManager\Config\BundleConfig; use Torr\TaskManager\DependencyInjection\AutoDetectFailureTransportsCompilerPass; use Torr\TaskManager\DependencyInjection\FindTaskClassesCompilerPass; -use Torr\TaskManager\DependencyInjection\TaskManagerBundleConfiguration; -use Torr\TaskManager\Log\LogCleaner; +use Torr\TaskManager\DependencyInjection\TaskManagerBundleExtension; use Torr\TaskManager\Task\Task; final class TaskManagerBundle extends Bundle @@ -20,26 +17,7 @@ final class TaskManagerBundle extends Bundle */ public function getContainerExtension () : ExtensionInterface { - return new ConfigurableBundleExtension( - $this, - new TaskManagerBundleConfiguration(), - static function (array $config, ContainerBuilder $container) : void - { - $container->getDefinition(BundleConfig::class) - ->setArgument('$sortedQueues', $config["queues"]); - - // if the new value was customized, use it. Otherwise keep using - // the old value. If none is set, they use the same default, so everything - // is fine. - $logTtl = 28 !== $config["log"]["ttl"] - ? $config["log"]["ttl"] - : $config["log_ttl"]; - - $container->getDefinition(LogCleaner::class) - ->setArgument('$logTtlInDays', $logTtl) - ->setArgument('$logMaxEntries', $config["log"]["max_entries"]); - }, - ); + return new TaskManagerBundleExtension($this, "task_manager"); } /**