Remove Subscriber
This commit is contained in:
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Nsq;
|
||||
|
||||
use Generator;
|
||||
use Nsq\Config\ClientConfig;
|
||||
use Nsq\Exception\NsqError;
|
||||
use Nsq\Exception\NsqException;
|
||||
@ -34,6 +35,24 @@ final class Consumer extends Connection
|
||||
$this->command('SUB', [$this->topic, $this->channel])->checkIsOK();
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return Generator<int, Message|float|null, int|null, void>
|
||||
*/
|
||||
public function generator(): Generator
|
||||
{
|
||||
while (true) {
|
||||
$this->rdy(1);
|
||||
|
||||
$command = yield $this->readMessage();
|
||||
|
||||
if (0 === $command) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
public function readMessage(): ?Message
|
||||
{
|
||||
$frame = $this->readFrame();
|
||||
|
Reference in New Issue
Block a user