From f3c0a33762bf6b7f63f947bd18a07785ec526264 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Mon, 16 Oct 2023 22:00:13 +0400 Subject: [PATCH 1/3] Add WorkflowClientCallsInterceptorTrait; fix signature of WorkflowOutboundCallsInterceptor interface --- .../WorkflowClientCallsInterceptorTrait.php | 1 - .../WorkflowOutboundCallsInterceptorTrait.php | 149 ++++++++++++++++++ .../WorkflowOutboundCallsInterceptor.php | 45 +++--- 3 files changed, 172 insertions(+), 23 deletions(-) create mode 100644 src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php diff --git a/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php b/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php index 50cba370..134920a4 100644 --- a/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php +++ b/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php @@ -24,7 +24,6 @@ /** * Implements {@see WorkflowClientCallsInterceptor} - * @psalm-immutable */ trait WorkflowClientCallsInterceptorTrait { diff --git a/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php b/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php new file mode 100644 index 00000000..3bea8f01 --- /dev/null +++ b/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php @@ -0,0 +1,149 @@ + Date: Mon, 16 Oct 2023 22:07:02 +0400 Subject: [PATCH 2/3] Transport Client now carries Workflow contexts instead of just info. It is required to resolve promises in the right context. --- src/Internal/Support/Facade.php | 1 + src/Internal/Transport/Client.php | 16 ++++++++++------ src/Internal/Transport/ClientInterface.php | 6 +++--- src/Internal/Workflow/Process/Scope.php | 4 ++-- src/Internal/Workflow/WorkflowContext.php | 2 +- tests/Feature/Testing/CapturedClient.php | 4 ++-- tests/Feature/Testing/TestingClient.php | 5 +++-- tests/Unit/Framework/ClientMock.php | 4 ++-- 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Internal/Support/Facade.php b/src/Internal/Support/Facade.php index 810366d8..724054dd 100644 --- a/src/Internal/Support/Facade.php +++ b/src/Internal/Support/Facade.php @@ -53,6 +53,7 @@ public static function __callStatic(string $name, array $arguments) /** * @param object|null $ctx + * @internal */ public static function setCurrentContext(?object $ctx): void { diff --git a/src/Internal/Transport/Client.php b/src/Internal/Transport/Client.php index a589d1a6..7da111a8 100644 --- a/src/Internal/Transport/Client.php +++ b/src/Internal/Transport/Client.php @@ -21,7 +21,8 @@ use Temporal\Worker\Transport\Command\RequestInterface; use Temporal\Worker\Transport\Command\ResponseInterface; use Temporal\Worker\Transport\Command\SuccessResponseInterface; -use Temporal\Workflow\WorkflowInfo; +use Temporal\Workflow; +use Temporal\Workflow\WorkflowContextInterface; /** * @internal Client is an internal library class, please do not use it in your code. @@ -38,7 +39,7 @@ final class Client implements ClientInterface 'a request with that identifier was not sent'; /** - * @var array + * @var array */ private array $requests = []; @@ -64,14 +65,17 @@ public function dispatch(ResponseInterface $response): void return; } - [$deferred, $info] = $this->requests[$id]; + [$deferred, $context] = $this->requests[$id]; unset($this->requests[$id]); + $info = $context->getInfo(); if ($info !== null && $response->getHistoryLength() > $info->historyLength) { /** @psalm-suppress InaccessibleProperty */ $info->historyLength = $response->getHistoryLength(); } + // Bind workflow context for promise resolution + Workflow::setCurrentContext($context); if ($response instanceof FailureResponseInterface) { $deferred->reject($response->getFailure()); } else { @@ -81,11 +85,11 @@ public function dispatch(ResponseInterface $response): void /** * @param RequestInterface $request - * @param null|WorkflowInfo $workflowInfo + * @param null|WorkflowContextInterface $context * * @return PromiseInterface */ - public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = null): PromiseInterface + public function request(RequestInterface $request, ?WorkflowContextInterface $context = null): PromiseInterface { $this->queue->push($request); @@ -96,7 +100,7 @@ public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = } $deferred = new Deferred(); - $this->requests[$id] = [$deferred, $workflowInfo]; + $this->requests[$id] = [$deferred, $context]; return $deferred->promise(); } diff --git a/src/Internal/Transport/ClientInterface.php b/src/Internal/Transport/ClientInterface.php index adb2e95c..56020d0b 100644 --- a/src/Internal/Transport/ClientInterface.php +++ b/src/Internal/Transport/ClientInterface.php @@ -14,17 +14,17 @@ use React\Promise\PromiseInterface; use Temporal\Worker\Transport\Command\CommandInterface; use Temporal\Worker\Transport\Command\RequestInterface; -use Temporal\Workflow\WorkflowInfo; +use Temporal\Workflow\WorkflowContextInterface; interface ClientInterface { /** * @param RequestInterface $request - * @param null|WorkflowInfo $workflowInfo + * @param null|WorkflowContextInterface $context * * @return PromiseInterface */ - public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = null): PromiseInterface; + public function request(RequestInterface $request, ?WorkflowContextInterface $context = null): PromiseInterface; /** * @param CommandInterface $command diff --git a/src/Internal/Workflow/Process/Scope.php b/src/Internal/Workflow/Process/Scope.php index 0cca4b64..b394c5e3 100644 --- a/src/Internal/Workflow/Process/Scope.php +++ b/src/Internal/Workflow/Process/Scope.php @@ -422,7 +422,7 @@ protected function onRequest(RequestInterface $request, PromiseInterface $promis return; } - $this->context->getClient()->request(new Cancel($request->getID())); + $this->context->getClient()->request(new Cancel($request->getID()), $this->scopeContext); }; $cancelID = $this->cancelID; @@ -471,7 +471,7 @@ protected function next(): void break; case $current instanceof RequestInterface: - $this->nextPromise($this->context->getClient()->request($current, $this->scopeContext->getInfo())); + $this->nextPromise($this->context->getClient()->request($current, $this->scopeContext)); break; case $current instanceof \Generator: diff --git a/src/Internal/Workflow/WorkflowContext.php b/src/Internal/Workflow/WorkflowContext.php index a66bcd1e..cac298e2 100644 --- a/src/Internal/Workflow/WorkflowContext.php +++ b/src/Internal/Workflow/WorkflowContext.php @@ -507,7 +507,7 @@ public function request(RequestInterface $request, bool $cancellable = true): Pr // Intercept workflow outbound calls return $this->requestInterceptor->with( function (RequestInterface $request): PromiseInterface { - return $this->client->request($request, $this->getInfo()); + return $this->client->request($request, $this); }, /** @see WorkflowOutboundRequestInterceptor::handleOutboundRequest() */ 'handleOutboundRequest', diff --git a/tests/Feature/Testing/CapturedClient.php b/tests/Feature/Testing/CapturedClient.php index cc63efe8..86f26992 100644 --- a/tests/Feature/Testing/CapturedClient.php +++ b/tests/Feature/Testing/CapturedClient.php @@ -15,7 +15,7 @@ use Temporal\Internal\Transport\ClientInterface; use Temporal\Worker\Transport\Command\CommandInterface; use Temporal\Worker\Transport\Command\RequestInterface; -use Temporal\Workflow\WorkflowInfo; +use Temporal\Workflow\WorkflowContextInterface; class CapturedClient implements ClientInterface { @@ -41,7 +41,7 @@ public function __construct(ClientInterface $parent) * @param RequestInterface $request * @return PromiseInterface */ - public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = null): PromiseInterface + public function request(RequestInterface $request, ?WorkflowContextInterface $context = null): PromiseInterface { return $this->requests[$request->getID()] = $this->parent->request($request) ->then($this->onFulfilled($request), $this->onRejected($request)); diff --git a/tests/Feature/Testing/TestingClient.php b/tests/Feature/Testing/TestingClient.php index 2d7cbb52..2f158dd9 100644 --- a/tests/Feature/Testing/TestingClient.php +++ b/tests/Feature/Testing/TestingClient.php @@ -19,6 +19,7 @@ use Temporal\Worker\Transport\Command\FailureResponse; use Temporal\Worker\Transport\Command\RequestInterface; use Temporal\Worker\Transport\Command\SuccessResponse; +use Temporal\Workflow\WorkflowContextInterface; use Temporal\Workflow\WorkflowInfo; class TestingClient extends CapturedClient @@ -70,12 +71,12 @@ public function error(RequestInterface $request, \Throwable $error): TestingFail /** * {@inheritDoc} */ - public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = null): PromiseInterface + public function request(RequestInterface $request, ?WorkflowContextInterface $context = null): PromiseInterface { if (!$request instanceof TestingRequest) { $request = new TestingRequest($request); } - return parent::request($request, $workflowInfo); + return parent::request($request, $context); } } diff --git a/tests/Unit/Framework/ClientMock.php b/tests/Unit/Framework/ClientMock.php index 55ae24a3..e557302a 100644 --- a/tests/Unit/Framework/ClientMock.php +++ b/tests/Unit/Framework/ClientMock.php @@ -15,7 +15,7 @@ use Temporal\Worker\Transport\Command\RequestInterface; use Temporal\Worker\Transport\Command\ResponseInterface; use Temporal\Worker\Transport\Command\SuccessResponseInterface; -use Temporal\Workflow\WorkflowInfo; +use Temporal\Workflow\WorkflowContextInterface; /** * @internal @@ -60,7 +60,7 @@ public function dispatch(ResponseInterface $response): void } } - public function request(RequestInterface $request, ?WorkflowInfo $workflowInfo = null): PromiseInterface + public function request(RequestInterface $request, ?WorkflowContextInterface $context = null): PromiseInterface { $this->queue->push($request); From 5ef06ca020419efdaf7cf1c18ade08e42dc9b03d Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Wed, 18 Oct 2023 22:29:01 +0400 Subject: [PATCH 3/3] Make all properties in interceptor configs readonly. Activity input: add activity method reflection when possible --- .../ActivityInbound/ActivityInput.php | 8 ++--- .../WorkflowClient/CancelInput.php | 5 +-- .../WorkflowClient/GetResultInput.php | 14 +++----- src/Interceptor/WorkflowClient/QueryInput.php | 14 +++----- .../WorkflowClient/SignalInput.php | 14 +++----- .../WorkflowClient/SignalWithStartInput.php | 11 ++----- src/Interceptor/WorkflowClient/StartInput.php | 17 +++------- .../WorkflowClient/TerminateInput.php | 8 ++--- .../WorkflowInbound/QueryInput.php | 8 ++--- .../WorkflowInbound/SignalInput.php | 14 +++----- .../WorkflowInbound/WorkflowInput.php | 11 ++----- .../WorkflowOutboundCalls/AwaitInput.php | 5 +-- .../AwaitWithTimeoutInput.php | 15 +++++---- .../CancelExternalWorkflowInput.php | 19 +++++------ .../WorkflowOutboundCalls/CompleteInput.php | 16 ++++++---- .../ContinueAsNewInput.php | 18 ++++++----- .../ExecuteActivityInput.php | 32 ++++++++++++------- .../ExecuteChildWorkflowInput.php | 21 ++++++------ .../ExecuteLocalActivityInput.php | 32 ++++++++++++------- .../WorkflowOutboundCalls/GetVersionInput.php | 20 ++++++------ .../WorkflowOutboundCalls/PanicInput.php | 16 ++++++---- .../WorkflowOutboundCalls/SideEffectInput.php | 16 ++++++---- .../SignalExternalWorkflowInput.php | 27 ++++++++-------- .../WorkflowOutboundCalls/TimerInput.php | 16 ++++++---- .../UpsertSearchAttributesInput.php | 13 +++++--- .../Prototype/ActivityPrototype.php | 11 +++++-- src/Internal/Workflow/ActivityProxy.php | 23 +++++++++++-- 27 files changed, 214 insertions(+), 210 deletions(-) diff --git a/src/Interceptor/ActivityInbound/ActivityInput.php b/src/Interceptor/ActivityInbound/ActivityInput.php index 339eedc9..6a7b18de 100644 --- a/src/Interceptor/ActivityInbound/ActivityInput.php +++ b/src/Interceptor/ActivityInbound/ActivityInput.php @@ -9,14 +9,12 @@ namespace Temporal\Interceptor\ActivityInbound; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; use Temporal\Interceptor\HeaderInterface; /** * @psalm-immutable */ -#[Immutable] class ActivityInput { /** @@ -24,10 +22,8 @@ class ActivityInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public ValuesInterface $arguments, - #[Immutable] - public HeaderInterface $header, + public readonly ValuesInterface $arguments, + public readonly HeaderInterface $header, ) { } diff --git a/src/Interceptor/WorkflowClient/CancelInput.php b/src/Interceptor/WorkflowClient/CancelInput.php index 0b64218b..0427b443 100644 --- a/src/Interceptor/WorkflowClient/CancelInput.php +++ b/src/Interceptor/WorkflowClient/CancelInput.php @@ -9,13 +9,11 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\Workflow\WorkflowExecution; /** * @psalm-immutable */ -#[Immutable] class CancelInput { /** @@ -23,8 +21,7 @@ class CancelInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowExecution $workflowExecution, + public readonly WorkflowExecution $workflowExecution, ) { } diff --git a/src/Interceptor/WorkflowClient/GetResultInput.php b/src/Interceptor/WorkflowClient/GetResultInput.php index 5119638d..f848d1af 100644 --- a/src/Interceptor/WorkflowClient/GetResultInput.php +++ b/src/Interceptor/WorkflowClient/GetResultInput.php @@ -9,13 +9,11 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\Workflow\WorkflowExecution; /** * @psalm-immutable */ -#[Immutable] class GetResultInput { /** @@ -23,14 +21,10 @@ class GetResultInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowExecution $workflowExecution, - #[Immutable] - public ?string $workflowType, - #[Immutable] - public ?int $timeout, - #[Immutable] - public mixed $type, + public readonly WorkflowExecution $workflowExecution, + public readonly ?string $workflowType, + public readonly ?int $timeout, + public readonly mixed $type, ) { } diff --git a/src/Interceptor/WorkflowClient/QueryInput.php b/src/Interceptor/WorkflowClient/QueryInput.php index a4748c0f..91e1bd02 100644 --- a/src/Interceptor/WorkflowClient/QueryInput.php +++ b/src/Interceptor/WorkflowClient/QueryInput.php @@ -9,14 +9,12 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; use Temporal\Workflow\WorkflowExecution; /** * @psalm-immutable */ -#[Immutable] class QueryInput { /** @@ -24,14 +22,10 @@ class QueryInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowExecution $workflowExecution, - #[Immutable] - public ?string $workflowType, - #[Immutable] - public string $queryType, - #[Immutable] - public ValuesInterface $arguments, + public readonly WorkflowExecution $workflowExecution, + public readonly ?string $workflowType, + public readonly string $queryType, + public readonly ValuesInterface $arguments, ) { } diff --git a/src/Interceptor/WorkflowClient/SignalInput.php b/src/Interceptor/WorkflowClient/SignalInput.php index a1743117..a221f74c 100644 --- a/src/Interceptor/WorkflowClient/SignalInput.php +++ b/src/Interceptor/WorkflowClient/SignalInput.php @@ -9,14 +9,12 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; use Temporal\Workflow\WorkflowExecution; /** * @psalm-immutable */ -#[Immutable] class SignalInput { /** @@ -24,14 +22,10 @@ class SignalInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowExecution $workflowExecution, - #[Immutable] - public ?string $workflowType, - #[Immutable] - public string $signalName, - #[Immutable] - public ValuesInterface $arguments, + public readonly WorkflowExecution $workflowExecution, + public readonly ?string $workflowType, + public readonly string $signalName, + public readonly ValuesInterface $arguments, ) { } diff --git a/src/Interceptor/WorkflowClient/SignalWithStartInput.php b/src/Interceptor/WorkflowClient/SignalWithStartInput.php index ff96bc8f..a86eb195 100644 --- a/src/Interceptor/WorkflowClient/SignalWithStartInput.php +++ b/src/Interceptor/WorkflowClient/SignalWithStartInput.php @@ -9,13 +9,11 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; /** * @psalm-immutable */ -#[Immutable] class SignalWithStartInput { /** @@ -23,12 +21,9 @@ class SignalWithStartInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public StartInput $workflowStartInput, - #[Immutable] - public string $signalName, - #[Immutable] - public ValuesInterface $signalArguments, + public readonly StartInput $workflowStartInput, + public readonly string $signalName, + public readonly ValuesInterface $signalArguments, ) { } diff --git a/src/Interceptor/WorkflowClient/StartInput.php b/src/Interceptor/WorkflowClient/StartInput.php index fc323569..5a27a56a 100644 --- a/src/Interceptor/WorkflowClient/StartInput.php +++ b/src/Interceptor/WorkflowClient/StartInput.php @@ -9,7 +9,6 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\Client\WorkflowOptions; use Temporal\DataConverter\ValuesInterface; use Temporal\Interceptor\HeaderInterface; @@ -17,7 +16,6 @@ /** * @psalm-immutable */ -#[Immutable] class StartInput { /** @@ -25,16 +23,11 @@ class StartInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public string $workflowId, - #[Immutable] - public string $workflowType, - #[Immutable] - public HeaderInterface $header, - #[Immutable] - public ValuesInterface $arguments, - #[Immutable] - public WorkflowOptions $options, + public readonly string $workflowId, + public readonly string $workflowType, + public readonly HeaderInterface $header, + public readonly ValuesInterface $arguments, + public readonly WorkflowOptions $options, ) { } diff --git a/src/Interceptor/WorkflowClient/TerminateInput.php b/src/Interceptor/WorkflowClient/TerminateInput.php index 365db5b9..aea63869 100644 --- a/src/Interceptor/WorkflowClient/TerminateInput.php +++ b/src/Interceptor/WorkflowClient/TerminateInput.php @@ -9,13 +9,11 @@ namespace Temporal\Interceptor\WorkflowClient; -use JetBrains\PhpStorm\Immutable; use Temporal\Workflow\WorkflowExecution; /** * @psalm-immutable */ -#[Immutable] class TerminateInput { /** @@ -23,10 +21,8 @@ class TerminateInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowExecution $workflowExecution, - #[Immutable] - public string $reason, + public readonly WorkflowExecution $workflowExecution, + public readonly string $reason, ) { } diff --git a/src/Interceptor/WorkflowInbound/QueryInput.php b/src/Interceptor/WorkflowInbound/QueryInput.php index 2234bcf0..eacb568f 100644 --- a/src/Interceptor/WorkflowInbound/QueryInput.php +++ b/src/Interceptor/WorkflowInbound/QueryInput.php @@ -9,13 +9,11 @@ namespace Temporal\Interceptor\WorkflowInbound; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; /** * @psalm-immutable */ -#[Immutable] class QueryInput { /** @@ -23,10 +21,8 @@ class QueryInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public string $queryName, - #[Immutable] - public ValuesInterface $arguments, + public readonly string $queryName, + public readonly ValuesInterface $arguments, ) { } diff --git a/src/Interceptor/WorkflowInbound/SignalInput.php b/src/Interceptor/WorkflowInbound/SignalInput.php index b461008f..fb646936 100644 --- a/src/Interceptor/WorkflowInbound/SignalInput.php +++ b/src/Interceptor/WorkflowInbound/SignalInput.php @@ -9,7 +9,6 @@ namespace Temporal\Interceptor\WorkflowInbound; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; use Temporal\Interceptor\HeaderInterface; use Temporal\Workflow\WorkflowInfo; @@ -17,7 +16,6 @@ /** * @psalm-immutable */ -#[Immutable] class SignalInput { /** @@ -25,14 +23,10 @@ class SignalInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public string $signalName, - #[Immutable] - public WorkflowInfo $info, - #[Immutable] - public ValuesInterface $arguments, - #[Immutable] - public HeaderInterface $header, + public readonly string $signalName, + public readonly WorkflowInfo $info, + public readonly ValuesInterface $arguments, + public readonly HeaderInterface $header, ) { } diff --git a/src/Interceptor/WorkflowInbound/WorkflowInput.php b/src/Interceptor/WorkflowInbound/WorkflowInput.php index 4c8fc08b..c0957e0d 100644 --- a/src/Interceptor/WorkflowInbound/WorkflowInput.php +++ b/src/Interceptor/WorkflowInbound/WorkflowInput.php @@ -9,7 +9,6 @@ namespace Temporal\Interceptor\WorkflowInbound; -use JetBrains\PhpStorm\Immutable; use Temporal\DataConverter\ValuesInterface; use Temporal\Interceptor\HeaderInterface; use Temporal\Workflow\WorkflowInfo; @@ -17,7 +16,6 @@ /** * @psalm-immutable */ -#[Immutable] class WorkflowInput { /** @@ -25,12 +23,9 @@ class WorkflowInput * @internal Don't use the constructor. Use {@see self::with()} instead. */ public function __construct( - #[Immutable] - public WorkflowInfo $info, - #[Immutable] - public ValuesInterface $arguments, - #[Immutable] - public HeaderInterface $header, + public readonly WorkflowInfo $info, + public readonly ValuesInterface $arguments, + public readonly HeaderInterface $header, ) { } diff --git a/src/Interceptor/WorkflowOutboundCalls/AwaitInput.php b/src/Interceptor/WorkflowOutboundCalls/AwaitInput.php index 558b88d8..6c0c8e5b 100644 --- a/src/Interceptor/WorkflowOutboundCalls/AwaitInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/AwaitInput.php @@ -4,13 +4,11 @@ namespace Temporal\Interceptor\WorkflowOutboundCalls; -use JetBrains\PhpStorm\Immutable; use React\Promise\PromiseInterface; /** * @psalm-immutable */ -#[Immutable] final class AwaitInput { /** @@ -20,8 +18,7 @@ final class AwaitInput * @param array $conditions */ public function __construct( - #[Immutable] - public array $conditions, + public readonly array $conditions, ) { } diff --git a/src/Interceptor/WorkflowOutboundCalls/AwaitWithTimeoutInput.php b/src/Interceptor/WorkflowOutboundCalls/AwaitWithTimeoutInput.php index fabca53e..e9b0ea96 100644 --- a/src/Interceptor/WorkflowOutboundCalls/AwaitWithTimeoutInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/AwaitWithTimeoutInput.php @@ -1,17 +1,22 @@ $conditions */ public function __construct( - #[Immutable] - public DateInterval $interval, - #[Immutable] - public array $conditions, + public readonly DateInterval $interval, + public readonly array $conditions, ) { } diff --git a/src/Interceptor/WorkflowOutboundCalls/CancelExternalWorkflowInput.php b/src/Interceptor/WorkflowOutboundCalls/CancelExternalWorkflowInput.php index bf9b732e..9bcd5bb8 100644 --- a/src/Interceptor/WorkflowOutboundCalls/CancelExternalWorkflowInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/CancelExternalWorkflowInput.php @@ -1,15 +1,19 @@ type, $args ?? $this->args, $options ?? $this->options, - $returnType ?? $this->returnType + $returnType ?? $this->returnType, + $method ?? $this->method, ); } } diff --git a/src/Interceptor/WorkflowOutboundCalls/ExecuteChildWorkflowInput.php b/src/Interceptor/WorkflowOutboundCalls/ExecuteChildWorkflowInput.php index d5fd01df..e43a4cae 100644 --- a/src/Interceptor/WorkflowOutboundCalls/ExecuteChildWorkflowInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/ExecuteChildWorkflowInput.php @@ -1,16 +1,21 @@ type, $args ?? $this->args, $options ?? $this->options, - $returnType ?? $this->returnType + $returnType ?? $this->returnType, + $method ?? $this->method, ); } } diff --git a/src/Interceptor/WorkflowOutboundCalls/GetVersionInput.php b/src/Interceptor/WorkflowOutboundCalls/GetVersionInput.php index 049ba9b8..aa143ebb 100644 --- a/src/Interceptor/WorkflowOutboundCalls/GetVersionInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/GetVersionInput.php @@ -1,16 +1,19 @@ failure, diff --git a/src/Interceptor/WorkflowOutboundCalls/SideEffectInput.php b/src/Interceptor/WorkflowOutboundCalls/SideEffectInput.php index 5295fb7d..45c53aac 100644 --- a/src/Interceptor/WorkflowOutboundCalls/SideEffectInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/SideEffectInput.php @@ -1,16 +1,19 @@ callable, diff --git a/src/Interceptor/WorkflowOutboundCalls/SignalExternalWorkflowInput.php b/src/Interceptor/WorkflowOutboundCalls/SignalExternalWorkflowInput.php index 306ec531..e7e8c41e 100644 --- a/src/Interceptor/WorkflowOutboundCalls/SignalExternalWorkflowInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/SignalExternalWorkflowInput.php @@ -1,16 +1,21 @@ interval, diff --git a/src/Interceptor/WorkflowOutboundCalls/UpsertSearchAttributesInput.php b/src/Interceptor/WorkflowOutboundCalls/UpsertSearchAttributesInput.php index 33c4a797..cb494085 100644 --- a/src/Interceptor/WorkflowOutboundCalls/UpsertSearchAttributesInput.php +++ b/src/Interceptor/WorkflowOutboundCalls/UpsertSearchAttributesInput.php @@ -1,15 +1,19 @@ isLocalActivity = $interface instanceof LocalActivityInterface; parent::__construct($name, $handler, $class); diff --git a/src/Internal/Workflow/ActivityProxy.php b/src/Internal/Workflow/ActivityProxy.php index 5e3bd359..e1ea0a33 100644 --- a/src/Internal/Workflow/ActivityProxy.php +++ b/src/Internal/Workflow/ActivityProxy.php @@ -81,20 +81,39 @@ public function __call(string $method, array $args = []): PromiseInterface $options = $this->options->mergeWith($handler->getMethodRetry()); return $handler->isLocalActivity() + // Run local activity through an interceptor pipeline ? $this->callsInterceptor->with( fn(ExecuteLocalActivityInput $input): PromiseInterface => $this->ctx ->newUntypedActivityStub($input->options) ->execute($input->type, $input->args, $input->returnType), /** @see WorkflowOutboundCallsInterceptor::executeLocalActivity() */ 'executeLocalActivity', - )(new ExecuteLocalActivityInput($handler->getID(), $args, $options, $type)) + )( + new ExecuteLocalActivityInput( + $handler->getID(), + $args, + $options, + $type, + $handler->getHandler(), + ) + ) + + // Run activity through an interceptor pipeline : $this->callsInterceptor->with( fn(ExecuteActivityInput $input): PromiseInterface => $this->ctx ->newUntypedActivityStub($input->options) ->execute($input->type, $input->args, $input->returnType), /** @see WorkflowOutboundCallsInterceptor::executeActivity() */ 'executeActivity', - )(new ExecuteActivityInput($handler->getID(), $args, $options, $type)); + )( + new ExecuteActivityInput( + $handler->getID(), + $args, + $options, + $type, + $handler->getHandler(), + ) + ); } /**