From 479b0b4fdae86811d5efcfee44cdddad6c411933 Mon Sep 17 00:00:00 2001 From: Aleksei Gagarin Date: Tue, 18 Apr 2023 13:32:58 +0400 Subject: [PATCH] Add supporting for RoadRunner `UndefinedResponse` command (#300) --- src/Internal/Transport/Client.php | 7 +++-- .../Transport/Request/UndefinedResponse.php | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/Internal/Transport/Request/UndefinedResponse.php diff --git a/src/Internal/Transport/Client.php b/src/Internal/Transport/Client.php index cd2f1dd7..9c59c27b 100644 --- a/src/Internal/Transport/Client.php +++ b/src/Internal/Transport/Client.php @@ -15,12 +15,12 @@ use React\Promise\PromiseInterface; use Temporal\Exception\Failure\CanceledFailure; use Temporal\Internal\Queue\QueueInterface; +use Temporal\Internal\Transport\Request\UndefinedResponse; use Temporal\Worker\Transport\Command\CommandInterface; use Temporal\Worker\Transport\Command\FailureResponseInterface; use Temporal\Worker\Transport\Command\RequestInterface; use Temporal\Worker\Transport\Command\ResponseInterface; use Temporal\Worker\Transport\Command\SuccessResponseInterface; -use Temporal\Worker\LoopInterface; /** * @internal Client is an internal library class, please do not use it in your code. @@ -54,7 +54,10 @@ public function __construct(QueueInterface $queue) public function dispatch(ResponseInterface $response): void { if (!isset($this->requests[$response->getID()])) { - throw new \LogicException(sprintf('Got the response to undefined request %s', $response->getID())); + $this->request(new UndefinedResponse( + \sprintf('Got the response to undefined request %s', $response->getID()), + )); + return; } $deferred = $this->fetch($response->getID()); diff --git a/src/Internal/Transport/Request/UndefinedResponse.php b/src/Internal/Transport/Request/UndefinedResponse.php new file mode 100644 index 00000000..4ae0a44a --- /dev/null +++ b/src/Internal/Transport/Request/UndefinedResponse.php @@ -0,0 +1,27 @@ + $message]); + } +}