Rename Reader to Consumer and Writer to Producer
This commit is contained in:
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Nsq;
|
||||
|
||||
class Reader extends Connection
|
||||
class Consumer extends Connection
|
||||
{
|
||||
/**
|
||||
* Subscribe to a topic/channel.
|
@@ -28,20 +28,20 @@ final class Message
|
||||
*/
|
||||
public string $body;
|
||||
|
||||
public function __construct(int $timestamp, int $attempts, string $id, string $body, Reader $reader)
|
||||
private bool $finished = false;
|
||||
|
||||
private Consumer $consumer;
|
||||
|
||||
public function __construct(int $timestamp, int $attempts, string $id, string $body, Consumer $consumer)
|
||||
{
|
||||
$this->timestamp = $timestamp;
|
||||
$this->attempts = $attempts;
|
||||
$this->id = $id;
|
||||
$this->body = $body;
|
||||
|
||||
$this->connection = $reader;
|
||||
$this->consumer = $consumer;
|
||||
}
|
||||
|
||||
private bool $finished = false;
|
||||
|
||||
private Reader $connection;
|
||||
|
||||
public function isFinished(): bool
|
||||
{
|
||||
return $this->finished;
|
||||
@@ -53,7 +53,7 @@ final class Message
|
||||
throw new LogicException('Can\'t finish message as it already finished.');
|
||||
}
|
||||
|
||||
$this->connection->fin($this->id);
|
||||
$this->consumer->fin($this->id);
|
||||
$this->finished = true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ final class Message
|
||||
throw new LogicException('Can\'t requeue message as it already finished.');
|
||||
}
|
||||
|
||||
$this->connection->req($this->id, $timeout);
|
||||
$this->consumer->req($this->id, $timeout);
|
||||
$this->finished = true;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,6 @@ final class Message
|
||||
throw new LogicException('Can\'t touch message as it already finished.');
|
||||
}
|
||||
|
||||
$this->connection->touch($this->id);
|
||||
$this->consumer->touch($this->id);
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ use function pack;
|
||||
use function sprintf;
|
||||
use const PHP_EOL;
|
||||
|
||||
final class Writer extends Connection
|
||||
final class Producer extends Connection
|
||||
{
|
||||
/**
|
||||
* @psalm-suppress PossiblyFalseOperand
|
@@ -44,7 +44,7 @@ final class Response
|
||||
return self::TYPE_RESPONSE === $this->type && self::HEARTBEAT === $this->buffer->bytes();
|
||||
}
|
||||
|
||||
public function toMessage(Reader $reader): Message
|
||||
public function toMessage(Consumer $reader): Message
|
||||
{
|
||||
if (self::TYPE_MESSAGE !== $this->type) {
|
||||
throw new Exception(sprintf('Expecting "%s" type, but NSQ return: "%s"', self::TYPE_MESSAGE, $this->type));
|
||||
|
@@ -14,9 +14,9 @@ final class Subscriber
|
||||
public const STOP = 0;
|
||||
public const CHANGE_TIMEOUT = 1;
|
||||
|
||||
private Reader $reader;
|
||||
private Consumer $reader;
|
||||
|
||||
public function __construct(Reader $reader)
|
||||
public function __construct(Consumer $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
Reference in New Issue
Block a user