From 0c877e3d12640d4aa57544df770f2f5ea716273b Mon Sep 17 00:00:00 2001 From: tinect Date: Tue, 29 Oct 2024 09:09:56 +0100 Subject: [PATCH] Feat/ignore unknown queue counts (#284) * chore: codestyle * feat: ignore transports without count support --- src/Command/UpdateComposerPluginsCommand.php | 2 +- .../Elasticsearch/AdminInfoSubscriberEventListener.php | 7 +++---- src/Components/Elasticsearch/ElasticsearchManager.php | 2 +- .../Health/Checker/HealthChecker/ProductionChecker.php | 2 +- .../Checker/HealthChecker/SwagSecurityChecker.php | 2 +- .../Health/Checker/HealthChecker/SystemInfoChecker.php | 2 +- .../Checker/PerformanceChecker/AdminWorkerChecker.php | 2 +- .../PerformanceChecker/CompressionMethodChecker.php | 10 +++++----- .../PerformanceChecker/FixCacheIdSetChecker.php | 2 +- .../PerformanceChecker/IncrementStorageChecker.php | 4 ++-- .../PerformanceChecker/MailOverQueueChecker.php | 2 +- .../PerformanceChecker/QueueConnectionChecker.php | 2 +- src/Components/StateMachines/Mermaid.php | 4 ++-- src/Components/StateMachines/Plantuml.php | 4 ++-- .../SystemConfig/ConfigSystemConfigLoader.php | 5 +++-- src/Controller/CacheController.php | 4 ++-- src/Controller/ElasticsearchController.php | 2 +- src/Controller/HealthController.php | 2 +- src/Controller/LogController.php | 4 ++-- src/Controller/QueueController.php | 7 +------ src/Controller/ScheduledTaskController.php | 2 +- src/Controller/ShopwareFilesController.php | 8 ++++---- src/Controller/StateMachineController.php | 2 +- 23 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/Command/UpdateComposerPluginsCommand.php b/src/Command/UpdateComposerPluginsCommand.php index b003698..4cf5e22 100644 --- a/src/Command/UpdateComposerPluginsCommand.php +++ b/src/Command/UpdateComposerPluginsCommand.php @@ -21,7 +21,7 @@ class UpdateComposerPluginsCommand extends Command private readonly Application $application; public function __construct( - #[Autowire('%kernel.project_dir%')] + #[Autowire(param: 'kernel.project_dir')] private readonly string $projectDir, private readonly KernelPluginLoader $pluginLoader, ) { diff --git a/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php b/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php index b5bc330..de8b61d 100644 --- a/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php +++ b/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php @@ -9,13 +9,12 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent; #[AutoconfigureTag('kernel.event_listener')] -final class AdminInfoSubscriberEventListener +final readonly class AdminInfoSubscriberEventListener { public function __construct( - #[Autowire('%frosh_tools.elasticsearch.enabled%')] - private readonly bool $elasticsearchEnabled, + #[Autowire(param: 'frosh_tools.elasticsearch.enabled')] + private bool $elasticsearchEnabled, ) {} - public function __invoke(ResponseEvent $event): void { if ($event->getRequest()->attributes->get('_route') !== 'api.info.config') { diff --git a/src/Components/Elasticsearch/ElasticsearchManager.php b/src/Components/Elasticsearch/ElasticsearchManager.php index 8432cc4..b0a3e76 100644 --- a/src/Components/Elasticsearch/ElasticsearchManager.php +++ b/src/Components/Elasticsearch/ElasticsearchManager.php @@ -19,7 +19,7 @@ class ElasticsearchManager { public function __construct( private readonly Client $client, - #[Autowire('%frosh_tools.elasticsearch.enabled%')] + #[Autowire(param: 'frosh_tools.elasticsearch.enabled')] private readonly bool $enabled, private readonly ElasticsearchIndexer $indexer, private readonly MessageBusInterface $messageBus, diff --git a/src/Components/Health/Checker/HealthChecker/ProductionChecker.php b/src/Components/Health/Checker/HealthChecker/ProductionChecker.php index a254997..ec53923 100644 --- a/src/Components/Health/Checker/HealthChecker/ProductionChecker.php +++ b/src/Components/Health/Checker/HealthChecker/ProductionChecker.php @@ -12,7 +12,7 @@ class ProductionChecker implements HealthCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%kernel.environment%')] + #[Autowire(param: 'kernel.environment')] private readonly string $environment, ) {} diff --git a/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php b/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php index 6649613..e502d7c 100644 --- a/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php @@ -22,7 +22,7 @@ class SwagSecurityChecker implements HealthCheckerInterface, CheckerInterface public function __construct( private readonly Connection $connection, private readonly KernelInterface $kernel, - #[Autowire('%kernel.shopware_version%')] + #[Autowire(param: 'kernel.shopware_version')] private readonly string $shopwareVersion, private readonly CacheInterface $cacheObject, #[Autowire(lazy: true)] diff --git a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php index a1fded3..c7b6ff2 100644 --- a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php @@ -13,7 +13,7 @@ class SystemInfoChecker implements HealthCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%kernel.project_dir%')] + #[Autowire(param: 'kernel.project_dir')] private readonly string $projectDir, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php index e72c653..6c04201 100644 --- a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php @@ -12,7 +12,7 @@ class AdminWorkerChecker implements PerformanceCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%shopware.admin_worker.enable_admin_worker%')] + #[Autowire(param: 'shopware.admin_worker.enable_admin_worker')] private readonly bool $adminWorkerEnabled, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php index af75b41..441d408 100644 --- a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php @@ -12,15 +12,15 @@ class CompressionMethodChecker implements PerformanceCheckerInterface, CheckerIn public const DOCUMENTATION_URL = 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#using-zstd-instead-of-gzip-for-compression'; public function __construct( - #[Autowire('%kernel.shopware_version%')] + #[Autowire(param: 'kernel.shopware_version')] public readonly string $shopwareVersion, - #[Autowire('%shopware.cache.cache_compression%')] + #[Autowire(param: 'shopware.cache.cache_compression')] public readonly bool $cacheCompressionEnabled, - #[Autowire('%shopware.cache.cache_compression_method%')] + #[Autowire(param: 'shopware.cache.cache_compression_method')] public readonly string $cacheCompressionMethod, - #[Autowire('%shopware.cart.compress%')] + #[Autowire(param: 'shopware.cart.compress')] public readonly bool $cartCompressionEnabled, - #[Autowire('%shopware.cart.compression_method%')] + #[Autowire(param: 'shopware.cart.compression_method')] public readonly string $cartCompressionMethod, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php b/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php index 4519e36..90bd348 100644 --- a/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php @@ -13,7 +13,7 @@ class FixCacheIdSetChecker implements PerformanceCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%kernel.shopware_version%')] + #[Autowire(param: 'kernel.shopware_version')] protected string $shopwareVersion, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php b/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php index 3a6d16c..55a6c44 100644 --- a/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php @@ -12,9 +12,9 @@ class IncrementStorageChecker implements PerformanceCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%shopware.increment.user_activity.type%')] + #[Autowire(param: 'shopware.increment.user_activity.type')] private readonly string $userActivity, - #[Autowire('%shopware.increment.message_queue.type%')] + #[Autowire(param: 'shopware.increment.message_queue.type')] private readonly string $queueActivity, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php b/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php index e9af127..a84e70c 100644 --- a/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php @@ -12,7 +12,7 @@ class MailOverQueueChecker implements PerformanceCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%frosh_tools.mail_over_queue%')] + #[Autowire(param: 'frosh_tools.mail_over_queue')] protected bool $mailerIsOverQueue, ) {} diff --git a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php index d3a13cf..a1414d6 100644 --- a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php @@ -12,7 +12,7 @@ class QueueConnectionChecker implements PerformanceCheckerInterface, CheckerInterface { public function __construct( - #[Autowire('%frosh_tools.queue_connection%')] + #[Autowire(param: 'frosh_tools.queue_connection')] protected string $connection, ) {} diff --git a/src/Components/StateMachines/Mermaid.php b/src/Components/StateMachines/Mermaid.php index f0a6b33..d46a79a 100644 --- a/src/Components/StateMachines/Mermaid.php +++ b/src/Components/StateMachines/Mermaid.php @@ -8,11 +8,11 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -final class Mermaid implements ExportInterface +final readonly class Mermaid implements ExportInterface { private const DEFAULT_PATH = __DIR__ . '/../../Resources/views/administration/mermaid'; - private readonly Environment $twig; + private Environment $twig; public function __construct() { diff --git a/src/Components/StateMachines/Plantuml.php b/src/Components/StateMachines/Plantuml.php index c8b74a3..2ef587e 100644 --- a/src/Components/StateMachines/Plantuml.php +++ b/src/Components/StateMachines/Plantuml.php @@ -8,11 +8,11 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -final class Plantuml implements ExportInterface +final readonly class Plantuml implements ExportInterface { private const DEFAULT_PATH = __DIR__ . '/../../Resources/views/administration/plantuml'; - private readonly Environment $twig; + private Environment $twig; public function __construct() { diff --git a/src/Components/SystemConfig/ConfigSystemConfigLoader.php b/src/Components/SystemConfig/ConfigSystemConfigLoader.php index a978d77..e1363af 100644 --- a/src/Components/SystemConfig/ConfigSystemConfigLoader.php +++ b/src/Components/SystemConfig/ConfigSystemConfigLoader.php @@ -2,12 +2,13 @@ namespace Frosh\Tools\Components\SystemConfig; +use Shopware\Core\System\SystemConfig\SystemConfigLoader; use Shopware\Core\System\SystemConfig\AbstractSystemConfigLoader; use Symfony\Component\DependencyInjection\Attribute\AsDecorator; use Symfony\Component\DependencyInjection\Attribute\Autowire; #[AsDecorator( - decorates: 'Shopware\Core\System\SystemConfig\SystemConfigLoader', + decorates: SystemConfigLoader::class, priority: 2000, )] class ConfigSystemConfigLoader extends AbstractSystemConfigLoader @@ -15,7 +16,7 @@ class ConfigSystemConfigLoader extends AbstractSystemConfigLoader /** * @param array|bool|float|int|string|null>> $config */ - public function __construct(private readonly AbstractSystemConfigLoader $decorated, #[Autowire('%frosh_tools.system_config%')] private readonly array $config) {} + public function __construct(private readonly AbstractSystemConfigLoader $decorated, #[Autowire(param: 'frosh_tools.system_config')] private readonly array $config) {} public function getDecorated(): AbstractSystemConfigLoader { diff --git a/src/Controller/CacheController.php b/src/Controller/CacheController.php index e5e0c28..3fd0d31 100644 --- a/src/Controller/CacheController.php +++ b/src/Controller/CacheController.php @@ -10,13 +10,13 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class CacheController extends AbstractController { public function __construct( - #[Autowire('%kernel.cache_dir%')] + #[Autowire(param: 'kernel.cache_dir')] private readonly string $cacheDir, private readonly CacheRegistry $cacheRegistry, ) {} diff --git a/src/Controller/ElasticsearchController.php b/src/Controller/ElasticsearchController.php index 622c898..20a14e2 100644 --- a/src/Controller/ElasticsearchController.php +++ b/src/Controller/ElasticsearchController.php @@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools/elasticsearch', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class ElasticsearchController extends AbstractController diff --git a/src/Controller/HealthController.php b/src/Controller/HealthController.php index adb515a..efa1bc9 100644 --- a/src/Controller/HealthController.php +++ b/src/Controller/HealthController.php @@ -10,7 +10,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class HealthController extends AbstractController diff --git a/src/Controller/LogController.php b/src/Controller/LogController.php index 5b91eb6..fa93e7d 100644 --- a/src/Controller/LogController.php +++ b/src/Controller/LogController.php @@ -12,7 +12,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class LogController extends AbstractController @@ -23,7 +23,7 @@ class LogController extends AbstractController private readonly string $logDir; public function __construct( - #[Autowire('%kernel.logs_dir%')] + #[Autowire(param: 'kernel.logs_dir')] string $logDir, ) { $this->logDir = rtrim($logDir, '/') . '/'; diff --git a/src/Controller/QueueController.php b/src/Controller/QueueController.php index e88cb03..529b3dd 100644 --- a/src/Controller/QueueController.php +++ b/src/Controller/QueueController.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface; use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class QueueController extends AbstractController @@ -69,11 +69,6 @@ private function getMessengerStats(array &$queueData): void $transport = $this->transportLocator->get($transportName); if (!$transport instanceof MessageCountAwareInterface) { - $queueData[] = [ - 'name' => $transportName, - 'size' => 'unknown', - ]; - continue; } diff --git a/src/Controller/ScheduledTaskController.php b/src/Controller/ScheduledTaskController.php index 82b44ed..37462d4 100644 --- a/src/Controller/ScheduledTaskController.php +++ b/src/Controller/ScheduledTaskController.php @@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class ScheduledTaskController extends AbstractController diff --git a/src/Controller/ShopwareFilesController.php b/src/Controller/ShopwareFilesController.php index 57cee91..960cdb6 100644 --- a/src/Controller/ShopwareFilesController.php +++ b/src/Controller/ShopwareFilesController.php @@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\HttpClient\HttpClientInterface; #[AutoconfigureTag('monolog.logger', ['channel' => 'frosh-tools'])] @@ -38,11 +38,11 @@ class ShopwareFilesController extends AbstractController * @param EntityRepository $integrationRepository */ public function __construct( - #[Autowire('%kernel.shopware_version%')] + #[Autowire(param: 'kernel.shopware_version')] private readonly string $shopwareVersion, - #[Autowire('%kernel.project_dir%')] + #[Autowire(param: 'kernel.project_dir')] private readonly string $projectDir, - #[Autowire('%frosh_tools.file_checker.exclude_files%')] + #[Autowire(param: 'frosh_tools.file_checker.exclude_files')] private readonly array $projectExcludeFiles, private readonly LoggerInterface $froshToolsLogger, private readonly EntityRepository $userRepository, diff --git a/src/Controller/StateMachineController.php b/src/Controller/StateMachineController.php index 54eb381..da907e3 100644 --- a/src/Controller/StateMachineController.php +++ b/src/Controller/StateMachineController.php @@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\System\StateMachine\StateMachineEntity;