Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@
<code><![CDATA[$options->namespace]]></code>
</DeprecatedProperty>
</file>
<file src="src/Client/Update/UpdateHandle.php">
<PossiblyNullArgument>
<code><![CDATA[$result->getSuccess()]]></code>
</PossiblyNullArgument>
</file>
<file src="src/Client/WorkflowClient.php">
<ArgumentTypeCoercion>
<code><![CDATA[$counter]]></code>
Expand Down
42 changes: 29 additions & 13 deletions src/Client/Update/UpdateHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,38 @@ private function fetchResult(int|float|null $timeout = null): void
(new \Temporal\Api\Update\V1\WaitPolicy())->setLifecycleStage(LifecycleStage::StageCompleted->value),
);

try {
$response = $this->client->PollWorkflowExecutionUpdate(
$request,
$timeout === null ? null : $this->client->getContext()->withTimeout($timeout),
);
} catch (TimeoutException|CanceledException $e) {
throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e);
}

// Workflow Uprate accepted
$result = $response->getOutcome();
\assert($result !== null);
$context = $timeout === null
? $this->client->getContext()
: $this->client->getContext()->withTimeout($timeout);
$deadline = $context->getDeadline();

// Convert request timeout into deadline
$deadline === null or $context = $context->withDeadline($deadline);

do {
try {
$response = $this->client->PollWorkflowExecutionUpdate($request, $context);
} catch (TimeoutException|CanceledException $e) {
throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e);
}

// Workflow Uprate accepted
$result = $response->getOutcome();

/**
* Retry the request.
*
* TimeoutException will be thrown in {@see \Temporal\Client\GRPC\BaseClient::call()} method
* because the deadline is provided in the context.
* That's why the deadline condition is not checked here.
*/
} while ($result === null);

// Accepted with result
if ($result->getSuccess() !== null) {
$this->result = EncodedValues::fromPayloads($result->getSuccess(), $this->converter);
$success = $result->getSuccess();
if ($success !== null) {
$this->result = EncodedValues::fromPayloads($success, $this->converter);
return;
}

Expand Down
8 changes: 0 additions & 8 deletions src/Exception/Failure/FailureConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Temporal\Exception\Failure;

use Psr\Log\LoggerInterface;
use Temporal\Api\Common\V1\ActivityType;
use Temporal\Api\Common\V1\WorkflowExecution;
use Temporal\Api\Common\V1\WorkflowType;
Expand All @@ -30,8 +29,6 @@

final class FailureConverter
{
private static ?LoggerInterface $logger;

public static function mapFailureToException(Failure $failure, DataConverterInterface $converter): TemporalFailure
{
$e = self::createFailureException($failure, $converter);
Expand Down Expand Up @@ -160,11 +157,6 @@ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterfa
return $failure;
}

public function setLogger(LoggerInterface $logger): void
{
self::$logger = $logger;
}

private static function createFailureException(Failure $failure, DataConverterInterface $converter): TemporalFailure
{
$previous = null;
Expand Down
Loading