Return Failure on try to write to NullStream

This commit is contained in:
2021-09-13 23:48:17 +03:00
parent 3c7686405d
commit 7984d09e83

View File

@ -4,10 +4,11 @@ declare(strict_types=1);
namespace Nsq\Stream; namespace Nsq\Stream;
use Amp\Failure;
use Amp\Promise; use Amp\Promise;
use Amp\Success; use Amp\Success;
use Nsq\Exception\NsqException;
use Nsq\Stream; use Nsq\Stream;
use function Amp\call;
final class NullStream implements Stream final class NullStream implements Stream
{ {
@ -24,8 +25,7 @@ final class NullStream implements Stream
*/ */
public function write(string $data): Promise public function write(string $data): Promise
{ {
return call(static function (): void { return new Failure(new NsqException('Connection closed.'));
});
} }
/** /**