Use constant for gracefully shutdown value
This commit is contained in:
@ -87,7 +87,7 @@ foreach ($generator as $envelope) {
|
||||
}
|
||||
|
||||
if ($stopSignalReceived) {
|
||||
$generator->send(true); // Gracefully close connection
|
||||
$generator->send(Subscriber::STOP); // Gracefully close connection
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -8,6 +8,8 @@ use Generator;
|
||||
|
||||
final class Subscriber extends Reader
|
||||
{
|
||||
public const STOP = true;
|
||||
|
||||
/**
|
||||
* @psalm-return Generator<int, Envelope|null, true|null, void>
|
||||
*/
|
||||
@ -20,14 +22,14 @@ final class Subscriber extends Reader
|
||||
$message = $this->consume($timeout);
|
||||
|
||||
if (null === $message) {
|
||||
if (true === yield null) {
|
||||
if (self::STOP === yield null) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (true === yield new Envelope($message, $this)) {
|
||||
if (self::STOP === yield new Envelope($message, $this)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user