Skip to content

Commit

Permalink
Fixing exchange handling (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 20, 2023
1 parent ba5c11e commit 9cc47d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Writers/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static function getSubscribedEvents(): array
}

/**
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down Expand Up @@ -145,6 +146,7 @@ public function stateChanged(
}

/**
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down
14 changes: 14 additions & 0 deletions src/Writers/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +55,8 @@ class Exchange extends Periodic implements Writer, ExchangeConsumers\Consumer
* @param DevicesModels\Configuration\Devices\Repository<MetadataDocuments\DevicesModule\Device> $devicesConfigurationRepository
* @param DevicesModels\Configuration\Channels\Repository<MetadataDocuments\DevicesModule\Channel> $channelsConfigurationRepository
* @param DevicesModels\Configuration\Channels\Properties\Repository<MetadataDocuments\DevicesModule\ChannelDynamicProperty|MetadataDocuments\DevicesModule\ChannelVariableProperty|MetadataDocuments\DevicesModule\ChannelMappedProperty> $channelsPropertiesConfigurationRepository
*
* @throws ExchangeExceptions\InvalidArgument
*/
public function __construct(
MetadataDocuments\DevicesModule\Connector $connector,
Expand Down Expand Up @@ -81,15 +84,26 @@ 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();

$this->consumer->enable(self::class);
}

/**
* @throws ExchangeExceptions\InvalidArgument
*/
public function disconnect(): void
{
parent::disconnect();
Expand Down
4 changes: 3 additions & 1 deletion src/Writers/Periodic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -114,6 +114,7 @@ public function disconnect(): void
}

/**
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down Expand Up @@ -145,6 +146,7 @@ private function handleCommunication(): void
}

/**
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down

0 comments on commit 9cc47d1

Please sign in to comment.