Skip to content

Commit

Permalink
Add supporting for RoadRunner UndefinedResponse command (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Apr 18, 2023
1 parent f0fc05c commit 479b0b4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Internal/Transport/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
27 changes: 27 additions & 0 deletions src/Internal/Transport/Request/UndefinedResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* This file is part of Temporal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Temporal\Internal\Transport\Request;

use Temporal\Worker\Transport\Command\Request;

final class UndefinedResponse extends Request
{
public const NAME = 'UndefinedResponse';

/**
* @param non-empty-string $message Error message
*/
public function __construct(string $message)
{
parent::__construct(self::NAME, ['message' => $message]);
}
}

0 comments on commit 479b0b4

Please sign in to comment.