Skip to content

Commit

Permalink
[devices-module] Use cache service (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 28, 2023
1 parent 57ff7ad commit 00e59a6
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 70 deletions.
1 change: 0 additions & 1 deletion src/API/ConnectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function __construct(
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getConnection(MetadataDocuments\DevicesModule\Device $device): TelevisionApi
{
Expand Down
7 changes: 0 additions & 7 deletions src/Clients/Television.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ final class Television implements Client

private EventLoop\TimerInterface|null $handlerTimer = null;

/**
* @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> $channelsPropertiesConfigurationRepository
*/
public function __construct(
private readonly MetadataDocuments\DevicesModule\Connector $connector,
private readonly API\ConnectionManager $connectionManager,
Expand All @@ -103,7 +98,6 @@ public function __construct(
* @throws Exceptions\Runtime
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function connect(): void
{
Expand Down Expand Up @@ -539,7 +533,6 @@ private function processDevice(MetadataDocuments\DevicesModule\Device $device):
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
private function createDeviceClient(MetadataDocuments\DevicesModule\Device $device): void
{
Expand Down
8 changes: 0 additions & 8 deletions src/Connector/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
use FastyBird\Connector\Viera\Entities;
use FastyBird\Connector\Viera\Queue;
use FastyBird\Connector\Viera\Writers;
use FastyBird\Library\Metadata\Documents as MetadataDocuments;
use FastyBird\Library\Metadata\Exceptions as MetadataExceptions;
use FastyBird\Library\Metadata\Types as MetadataTypes;
use FastyBird\Module\Devices\Connectors as DevicesConnectors;
use FastyBird\Module\Devices\Entities as DevicesEntities;
Expand Down Expand Up @@ -56,9 +54,6 @@ final class Connector implements DevicesConnectors\Connector

private EventLoop\TimerInterface|null $consumersTimer = null;

/**
* @param DevicesModels\Configuration\Connectors\Repository<MetadataDocuments\DevicesModule\Connector> $connectorsConfigurationRepository
*/
public function __construct(
private readonly DevicesEntities\Connectors\Connector $connector,
private readonly Clients\ClientFactory $clientFactory,
Expand All @@ -76,9 +71,6 @@ public function __construct(

/**
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function execute(): void
{
Expand Down
13 changes: 0 additions & 13 deletions src/Helpers/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
final class Device
{

/**
* @param DevicesModels\Configuration\Devices\Properties\Repository<MetadataDocuments\DevicesModule\DeviceVariableProperty> $devicesPropertiesConfigurationRepository
*/
public function __construct(
private readonly DevicesModels\Configuration\Devices\Properties\Repository $devicesPropertiesConfigurationRepository,
)
Expand All @@ -53,7 +50,6 @@ public function __construct(
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getIpAddress(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -80,7 +76,6 @@ public function getIpAddress(MetadataDocuments\DevicesModule\Device $device): st
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getPort(MetadataDocuments\DevicesModule\Device $device): int
{
Expand All @@ -107,7 +102,6 @@ public function getPort(MetadataDocuments\DevicesModule\Device $device): int
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function isEncrypted(MetadataDocuments\DevicesModule\Device $device): bool
{
Expand All @@ -134,7 +128,6 @@ public function isEncrypted(MetadataDocuments\DevicesModule\Device $device): boo
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getAppId(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -161,7 +154,6 @@ public function getAppId(MetadataDocuments\DevicesModule\Device $device): string
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getEncryptionKey(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -188,7 +180,6 @@ public function getEncryptionKey(MetadataDocuments\DevicesModule\Device $device)
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getModel(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -215,7 +206,6 @@ public function getModel(MetadataDocuments\DevicesModule\Device $device): string
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getManufacturer(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -242,7 +232,6 @@ public function getManufacturer(MetadataDocuments\DevicesModule\Device $device):
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getMacAddress(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -269,7 +258,6 @@ public function getMacAddress(MetadataDocuments\DevicesModule\Device $device): s
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getSerialNumber(MetadataDocuments\DevicesModule\Device $device): string|null
{
Expand All @@ -296,7 +284,6 @@ public function getSerialNumber(MetadataDocuments\DevicesModule\Device $device):
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function getStateReadingDelay(MetadataDocuments\DevicesModule\Device $device): float
{
Expand Down
5 changes: 0 additions & 5 deletions src/Queue/Consumers/StoreChannelPropertyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ final class StoreChannelPropertyState implements Queue\Consumer

use Nette\SmartObject;

/**
* @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> $channelsPropertiesConfigurationRepository
*/
public function __construct(
private readonly Viera\Logger $logger,
private readonly DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository,
Expand Down
7 changes: 0 additions & 7 deletions src/Queue/Consumers/StoreDeviceConnectionState.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use FastyBird\Connector\Viera\Entities;
use FastyBird\Connector\Viera\Queue;
use FastyBird\Library\Metadata;
use FastyBird\Library\Metadata\Documents as MetadataDocuments;
use FastyBird\Library\Metadata\Exceptions as MetadataExceptions;
use FastyBird\Library\Metadata\Types as MetadataTypes;
use FastyBird\Module\Devices\Exceptions as DevicesExceptions;
Expand All @@ -42,12 +41,6 @@ final class StoreDeviceConnectionState implements Queue\Consumer

use Nette\SmartObject;

/**
* @param DevicesModels\Configuration\Devices\Repository<MetadataDocuments\DevicesModule\Device> $devicesConfigurationRepository
* @param DevicesModels\Configuration\Devices\Properties\Repository<MetadataDocuments\DevicesModule\DeviceDynamicProperty> $devicesPropertiesConfigurationRepository
* @param DevicesModels\Configuration\Channels\Repository<MetadataDocuments\DevicesModule\Channel> $channelsConfigurationRepository
* @param DevicesModels\Configuration\Channels\Properties\Repository<MetadataDocuments\DevicesModule\ChannelDynamicProperty> $channelsPropertiesConfigurationRepository
*/
public function __construct(
private readonly Viera\Logger $logger,
private readonly DevicesModels\Configuration\Devices\Repository $devicesConfigurationRepository,
Expand Down
6 changes: 0 additions & 6 deletions src/Queue/Consumers/WriteChannelPropertyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ final class WriteChannelPropertyState implements Queue\Consumer

use Nette\SmartObject;

/**
* @param DevicesModels\Configuration\Connectors\Repository<MetadataDocuments\DevicesModule\Connector> $connectorsConfigurationRepository
* @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> $channelsPropertiesConfigurationRepository
*/
public function __construct(
private readonly Queue\Queue $queue,
private readonly API\ConnectionManager $connectionManager,
Expand Down
9 changes: 0 additions & 9 deletions src/Writers/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use FastyBird\Connector\Viera\Queue;
use FastyBird\DateTimeFactory;
use FastyBird\Library\Metadata\Documents as MetadataDocuments;
use FastyBird\Library\Metadata\Exceptions as MetadataExceptions;
use FastyBird\Module\Devices\Events as DevicesEvents;
use FastyBird\Module\Devices\Exceptions as DevicesExceptions;
use FastyBird\Module\Devices\Models as DevicesModels;
Expand All @@ -43,11 +42,6 @@ class Event extends Periodic implements Writer, EventDispatcher\EventSubscriberI

public const NAME = 'event';

/**
* @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> $channelsPropertiesConfigurationRepository
*/
public function __construct(
MetadataDocuments\DevicesModule\Connector $connector,
Helpers\Entity $entityHelper,
Expand Down Expand Up @@ -84,9 +78,6 @@ public static function getSubscribedEvents(): array
/**
* @throws DevicesExceptions\InvalidState
* @throws Exceptions\Runtime
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function stateChanged(
DevicesEvents\ChannelPropertyStateEntityCreated|DevicesEvents\ChannelPropertyStateEntityUpdated $event,
Expand Down
7 changes: 0 additions & 7 deletions src/Writers/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ class Exchange extends Periodic implements Writer, ExchangeConsumers\Consumer
public const NAME = 'exchange';

/**
* @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> $channelsPropertiesConfigurationRepository
*
* @throws ExchangeExceptions\InvalidArgument
*/
public function __construct(
Expand Down Expand Up @@ -82,8 +78,6 @@ public function __construct(
/**
* @throws DevicesExceptions\InvalidState
* @throws ExchangeExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
*/
public function connect(): void
{
Expand All @@ -107,7 +101,6 @@ public function disconnect(): void
* @throws Exceptions\Runtime
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws MetadataExceptions\MalformedInput
*/
public function consume(
MetadataTypes\ModuleSource|MetadataTypes\PluginSource|MetadataTypes\ConnectorSource|MetadataTypes\AutomatorSource $source,
Expand Down
7 changes: 0 additions & 7 deletions src/Writers/Periodic.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ abstract class Periodic implements Writer

private EventLoop\TimerInterface|null $handlerTimer = null;

/**
* @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> $channelsPropertiesConfigurationRepository
*/
public function __construct(
protected readonly MetadataDocuments\DevicesModule\Connector $connector,
protected readonly Helpers\Entity $entityHelper,
Expand All @@ -88,8 +83,6 @@ public function __construct(

/**
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
*/
public function connect(): void
{
Expand Down
2 changes: 2 additions & 0 deletions tests/common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ services:
type: React\EventLoop\LoopInterface
}

cache.storage: Nette\Caching\Storages\MemoryStorage

contributteTranslation:
locales:
default: en_US
Expand Down

0 comments on commit 00e59a6

Please sign in to comment.