From 9cc47d1fbe6c32242ba5d79c1ec02506dada57ad Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 20 Nov 2023 11:02:47 +0000 Subject: [PATCH] Fixing exchange handling (#178) --- src/Writers/Event.php | 2 ++ src/Writers/Exchange.php | 14 ++++++++++++++ src/Writers/Periodic.php | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Writers/Event.php b/src/Writers/Event.php index c0933f0..034124f 100644 --- a/src/Writers/Event.php +++ b/src/Writers/Event.php @@ -85,6 +85,7 @@ public static function getSubscribedEvents(): array } /** + * @throws DevicesExceptions\InvalidArgument * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState @@ -145,6 +146,7 @@ public function stateChanged( } /** + * @throws DevicesExceptions\InvalidArgument * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState diff --git a/src/Writers/Exchange.php b/src/Writers/Exchange.php index c998f3d..a16fb35 100644 --- a/src/Writers/Exchange.php +++ b/src/Writers/Exchange.php @@ -25,6 +25,7 @@ use FastyBird\DateTimeFactory; use FastyBird\Library\Bootstrap\Helpers as BootstrapHelpers; use FastyBird\Library\Exchange\Consumers as ExchangeConsumers; +use FastyBird\Library\Exchange\Exceptions as ExchangeExceptions; use FastyBird\Library\Metadata\Documents as MetadataDocuments; use FastyBird\Library\Metadata\Exceptions as MetadataExceptions; use FastyBird\Library\Metadata\Types as MetadataTypes; @@ -54,6 +55,8 @@ class Exchange extends Periodic implements Writer, ExchangeConsumers\Consumer * @param DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository * @param DevicesModels\Configuration\Channels\Repository $channelsConfigurationRepository * @param DevicesModels\Configuration\Channels\Properties\Repository $channelsPropertiesConfigurationRepository + * + * @throws ExchangeExceptions\InvalidArgument */ public function __construct( MetadataDocuments\DevicesModule\Connector $connector, @@ -81,8 +84,16 @@ public function __construct( $dateTimeFactory, $eventLoop, ); + + $this->consumer->register($this, null, false); } + /** + * @throws DevicesExceptions\InvalidState + * @throws ExchangeExceptions\InvalidArgument + * @throws MetadataExceptions\InvalidArgument + * @throws MetadataExceptions\InvalidState + */ public function connect(): void { parent::connect(); @@ -90,6 +101,9 @@ public function connect(): void $this->consumer->enable(self::class); } + /** + * @throws ExchangeExceptions\InvalidArgument + */ public function disconnect(): void { parent::disconnect(); diff --git a/src/Writers/Periodic.php b/src/Writers/Periodic.php index 7e49fb3..59591a2 100644 --- a/src/Writers/Periodic.php +++ b/src/Writers/Periodic.php @@ -46,7 +46,7 @@ abstract class Periodic private const HANDLER_START_DELAY = 5.0; - private const HANDLER_DEBOUNCE_INTERVAL = 5_000.0; + private const HANDLER_DEBOUNCE_INTERVAL = 2_500.0; private const HANDLER_PROCESSING_INTERVAL = 0.01; @@ -114,6 +114,7 @@ public function disconnect(): void } /** + * @throws DevicesExceptions\InvalidArgument * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState @@ -145,6 +146,7 @@ private function handleCommunication(): void } /** + * @throws DevicesExceptions\InvalidArgument * @throws DevicesExceptions\InvalidState * @throws MetadataExceptions\InvalidArgument * @throws MetadataExceptions\InvalidState