Explode Response to Frames

This commit is contained in:
2021-01-30 17:14:19 +03:00
parent fc6b67cc92
commit f74b82a400
24 changed files with 367 additions and 148 deletions

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use Nsq\Consumer;
use Nsq\Exception\MessageAlreadyFinished;
use Nsq\Message;
use Nsq\Protocol\Message;
use PHPUnit\Framework\TestCase;
final class MessageTest extends TestCase

View File

@ -4,8 +4,8 @@ declare(strict_types=1);
use Nsq\Config\ClientConfig;
use Nsq\Consumer;
use Nsq\Message;
use Nsq\Producer;
use Nsq\Protocol\Message;
use Nsq\Subscriber;
use Nyholm\NSA;
use PHPUnit\Framework\TestCase;
@ -20,7 +20,7 @@ final class NsqTest extends TestCase
$consumer = new Consumer(
address: 'tcp://localhost:4150',
clientConfig: new ClientConfig(
heartbeatInterval: 1000,
heartbeatInterval: 3000,
readTimeout: 1,
),
);

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Protocol;
use Generator;
use Nsq\Protocol\ErrorType;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
final class ErrorTypeTest extends TestCase
{
/**
* @dataProvider data
*/
public function testConstructor(string $type, bool $isConnectionTerminated): void
{
$errorType = new ErrorType($type);
self::assertSame($isConnectionTerminated, $errorType->terminateConnection);
}
/**
* @return Generator<string, array<int, bool|string>>
*/
public function data(): Generator
{
foreach ((new ReflectionClass(ErrorType::class))->getConstants() as $constant => $isTerminated) {
yield $constant => [$constant, $isTerminated];
}
}
}