Add SubscriberTest

This commit is contained in:
2021-01-23 02:59:33 +03:00
parent 6e37bbd1ae
commit 5d407480db
2 changed files with 51 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ final class Subscriber
{
public const STOP = 0;
public const CHANGE_TIMEOUT = 1;
public const TIMEOUT = 2;
private Consumer $reader;
@@ -21,7 +22,7 @@ final class Subscriber
}
/**
* @psalm-return Generator<int, Message|null, int|float|null, void>
* @psalm-return Generator<int, Message|float|null, int|float|null, void>
*/
public function subscribe(string $topic, string $channel, float $timeout = 0): Generator
{
@@ -45,6 +46,10 @@ final class Subscriber
$timeout = $newTimeout;
}
if (self::TIMEOUT === $command) {
yield $timeout;
}
}
$this->reader->disconnect();