Skip to content

Commit

Permalink
QA fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Jan 10, 2022
1 parent ee6ac4c commit 5944f4e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
6 changes: 0 additions & 6 deletions redisdb_exchange_plugin/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ def handle(self) -> None:

# -----------------------------------------------------------------------------

def is_healthy(self) -> bool:
"""Check if exchange is healthy"""
return self.is_alive()

# -----------------------------------------------------------------------------

def register_consumer(
self,
consumer: IConsumer,
Expand Down
16 changes: 7 additions & 9 deletions src/Client/AsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use FastyBird\RedisDbExchangePlugin\Exceptions;
use Nette;
use Psr\EventDispatcher;
use Psr\Log;
use Ramsey\Uuid;
use React\EventLoop;
use React\Promise;
Expand Down Expand Up @@ -81,15 +80,11 @@ class AsyncClient implements IAsyncClient
/** @var EventLoop\LoopInterface */
private EventLoop\LoopInterface $eventLoop;

/** @var Log\LoggerInterface */
private Log\LoggerInterface $logger;

public function __construct(
string $channelName,
Connections\IConnection $connection,
EventLoop\LoopInterface $eventLoop,
?EventDispatcher\EventDispatcherInterface $dispatcher = null,
?Log\LoggerInterface $logger = null
?EventDispatcher\EventDispatcherInterface $dispatcher = null
) {
$this->channelName = $channelName;

Expand All @@ -104,8 +99,6 @@ public function __construct(

$this->dispatcher = $dispatcher;

$this->logger = $logger ?? new Log\NullLogger();

$this->identifier = Uuid\Uuid::uuid4()->toString();
}

Expand Down Expand Up @@ -349,6 +342,11 @@ private function handleMessage(RedisProtocol\Model\ModelInterface $message): voi
{
if ($message instanceof RedisProtocol\Model\MultiBulkReply) {
$array = $message->getValueNative();

if (!is_array($array)) {
return;
}

$type = array_shift($array);

// Pub/Sub messages are to be forwarded and should not be processed as request responses
Expand All @@ -367,7 +365,7 @@ private function handleMessage(RedisProtocol\Model\ModelInterface $message): voi
if (isset($array[0]) && isset($array[1]) && isset($array[2])) {
if ($this->dispatcher !== null) {
$this->dispatcher->dispatch(
new Events\PatternMessageReceivedEvent($array[0], $array[1], $array[2], $this)
new Events\PatternMessageReceivedEvent(strval($array[0]), strval($array[1]), strval($array[2]), $this)
);
}

Expand Down
5 changes: 0 additions & 5 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class Client implements IClient
/** @var string */
private string $identifier;

/** @var Connections\IConnection */
private Connections\IConnection $connection;

/** @var Predis\Client<mixed> */
private Predis\Client $redis;

Expand All @@ -51,8 +48,6 @@ public function __construct(
) {
$this->channelName = $channelName;

$this->connection = $connection;

$options = [
'scheme' => 'tcp',
'host' => $connection->getHost(),
Expand Down
6 changes: 3 additions & 3 deletions src/Subscribers/AsyncClientSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function handleMessage(Events\MessageReceivedEvent $event): void
}

try {
$data = Utils\ArrayHash::from(Utils\Json::decode($event->getPayload(), Utils\Json::FORCE_ARRAY));
$data = Utils\ArrayHash::from(Utils\Json::decode($event->getPayload(), Utils\Json::FORCE_ARRAY)); // @phpstan-ignore-line

if (
$data->offsetExists('origin')
Expand All @@ -98,7 +98,7 @@ public function handleMessage(Events\MessageReceivedEvent $event): void
$this->handle(
MetadataTypes\ModuleOriginType::get($data->offsetGet('origin')),
MetadataTypes\RoutingKeyType::get($data->offsetGet('routing_key')),
$data->offsetGet('data')
$data->offsetGet('data') // @phpstan-ignore-line
);

} else {
Expand Down Expand Up @@ -140,7 +140,7 @@ private function handle(
}

try {
$schema = $this->schemaLoader->loadByRoutingKey($routingKey->getValue());
$schema = $this->schemaLoader->loadByRoutingKey($routingKey->getValue()); // @phpstan-ignore-line

} catch (MetadataExceptions\InvalidArgumentException $ex) {
return;
Expand Down

0 comments on commit 5944f4e

Please sign in to comment.