Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK 2.7.0-beta #367

Merged
merged 109 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
89758d2
Update phpunit and psalm
roxblnfk Dec 2, 2022
8e9fe86
Update Roadrunner proto messages
roxblnfk Dec 6, 2022
1c8bb1d
Extract EncodedPayloads from EncodedValues; add EncodedHeader; transi…
roxblnfk Dec 6, 2022
30556c6
Add ability to get Header in an executed Workflow via Workflow::hetHe…
roxblnfk Dec 6, 2022
d90652d
Refactor EncodedPayloads
roxblnfk Dec 6, 2022
a86afa1
Add tests for Header in Workflow; add ability to declare Header with …
roxblnfk Dec 7, 2022
8174f00
Add tests for Header in Child Workflow
roxblnfk Dec 9, 2022
2df471a
Add RequestInterface::getHeader();
roxblnfk Dec 9, 2022
883f257
Update Workflow* classes
roxblnfk Dec 9, 2022
686be6b
Move Header parameter from workflow options to stub classes
roxblnfk Jan 3, 2023
f32a347
Support activity headers
roxblnfk Jan 4, 2023
fcc6f77
Cleanup
roxblnfk Jan 4, 2023
40628f8
Fix functional tests
roxblnfk Jan 4, 2023
9ec8c60
Fix ExecuteLocalActivity constructor
roxblnfk Jan 10, 2023
d0260df
Merge pull request #273 from roxblnfk/feature/interceptors: header su…
roxblnfk Jan 11, 2023
6ccb3f4
Add Interceptor and InterceptorProvider interfaces
roxblnfk Jan 11, 2023
1a76081
Inject InterceptorProvider into a worker and InvokeActivity route; fi…
roxblnfk Jan 11, 2023
672ab8b
Move InterceptorProvider from worker factory into ServiceContainer
roxblnfk Jan 11, 2023
83b4e8d
Add class parameter to InterceptorProvider; add interfaces: ActivityI…
roxblnfk Jan 11, 2023
1238ddf
Add request interception test
roxblnfk Feb 13, 2023
fb31547
Add WorkflowInboundInterceptor interface; add test for WorkflowInboun…
roxblnfk Feb 14, 2023
7da53f3
Implement interceptor calls using temporary dummy pipelines
roxblnfk Feb 14, 2023
9640427
Store Prototype in the Workflow/Activity instance
roxblnfk Feb 15, 2023
5cca0a7
Add Pipeline class
roxblnfk Feb 21, 2023
bb2ac80
Improve Pipeline; simplify InterceptorProvider; intercept Signal call…
roxblnfk Feb 22, 2023
af60b07
Update worker to include php files recursive; include interceptors.
roxblnfk Feb 27, 2023
4695023
Replace InterceptorProvider with PipelineProvider.
roxblnfk Feb 27, 2023
27e60ac
Add test for Workflow Query interception
roxblnfk Feb 28, 2023
a1e1edc
Make inputs for WorkflowInboundInterceptor methods
roxblnfk Feb 28, 2023
9365d52
Test workflow context leaking when Workflow Query is handling
roxblnfk Mar 1, 2023
fbe5532
Always clean static context after each action; repair workflow execut…
roxblnfk Mar 3, 2023
bac885c
Repair workflow signal interception:
roxblnfk Mar 3, 2023
2abf7a0
Repair Activity inbound interceptor, add ActivityInput;
roxblnfk Mar 3, 2023
2b69c28
Repair Workflow Signal call interception
roxblnfk Mar 6, 2023
b978181
Fix `ActivityContext::doNotCompleteOnReturn()` behavior; discard stat…
roxblnfk Mar 6, 2023
39a42ac
Skip test case that doesn't work on test server
roxblnfk Mar 6, 2023
4aa3370
Finalize some things: remove headers from QueryInput; move ActivityIn…
roxblnfk Mar 7, 2023
767c1d6
Rename `WorkflowOutboundInterceptor` to `WorkflowOutboundRequestInter…
roxblnfk Mar 7, 2023
9867e6d
Add draft for WorkflowClientCallsInterceptor with all Input classes
roxblnfk Mar 14, 2023
6256c95
Intercept `start` and `signal with start` client calls
roxblnfk Mar 14, 2023
5a513bb
Add test for `WorkflowClientCallsInterceptor::start()`
roxblnfk Mar 14, 2023
ec0021a
Test signalWithStart interception; fix WorkflowClientCallsInterceptor…
roxblnfk Mar 15, 2023
e56bffa
Make an interception for `WorkflowClientCallsInterceptor::signal()`; …
roxblnfk Mar 16, 2023
f90632e
Make an interception for `WorkflowClientCallsInterceptor::query()`;
roxblnfk Mar 17, 2023
e942a6b
Make an interception for `cancel()` and `terminate()` methods of `Wor…
roxblnfk Mar 17, 2023
0b94e40
Make an interception for `getResult()`method of `WorkflowClientCallsI…
roxblnfk Mar 17, 2023
63be296
Fix some psalm types. Disable test InterceptRequestTestCase::testQuer…
roxblnfk Mar 20, 2023
ad87421
Merge branch 'master' into feature/interceptors
roxblnfk Mar 20, 2023
998292e
Comment test that doesn't work on the new test server
roxblnfk Mar 20, 2023
6f2cbb5
Merge pull request #293: add interceptors
roxblnfk Apr 3, 2023
361d733
Remove `getHeader()` methods from a public API
roxblnfk Apr 3, 2023
70cb4a2
Remove `getHeader()` methods from a public API; add HeaderCarrier int…
roxblnfk Apr 4, 2023
b7b9394
Remove `HeaderInterface` from public signatures
roxblnfk Apr 4, 2023
4a3edc7
RequestInterface: add HeaderCarrier interface; refactor header and in…
roxblnfk Apr 6, 2023
9759da3
Fix Header tests
roxblnfk Apr 8, 2023
565f48f
Merge pull request #295: Remove Headers from public API.
roxblnfk Apr 10, 2023
bc6e9ac
Move interceptor interfaces into internal dir
roxblnfk Apr 10, 2023
8f8dc90
Move all non-internal interceptor-related classes into Temporal\Inter…
roxblnfk Apr 10, 2023
3e52abf
Prepare context before interceptors pipeline run; polishing
roxblnfk Apr 12, 2023
133fd82
Intercept requests: UpsertSearchAttributes, SideEffect, Cancel, Cance…
roxblnfk Apr 18, 2023
2655949
All interceptor preset method collections are now traits
roxblnfk Apr 19, 2023
5ba42c7
Cleanup
roxblnfk Apr 20, 2023
a3b8984
Intercept ExecuteActivity calls
roxblnfk Apr 20, 2023
e5bb80b
Intercept executeChildWorkflow calls
roxblnfk Apr 20, 2023
52cd3a4
Intercept cancelExternalWorkflow and signalExternalWorkflow calls
roxblnfk Apr 21, 2023
b02d1ce
Merge pull request #301 from roxblnfk/interceptors: make a stable core
roxblnfk Apr 24, 2023
24626f9
Merge remote-tracking branch 'temporalio/master' into interceptors
roxblnfk Apr 24, 2023
0107bff
Intercept timer() and sideEffect() calls
roxblnfk May 1, 2023
cd18a43
Intercept panic() calls
roxblnfk May 4, 2023
fae2573
Set Activity context when interceptors pipeline is called; fix interc…
roxblnfk May 4, 2023
329b987
Merge pull request #303: add WorkflowOutboundCallsInterceptor
roxblnfk May 5, 2023
73047f7
Add client gRPC calls interceptor interface with tests
roxblnfk May 17, 2023
e54347d
Intercept `Workflow::continueAsNew` calls
roxblnfk May 21, 2023
0ef7fad
Intercept `Workflow::getVersion` calls
roxblnfk May 21, 2023
a70f026
Intercept `Workflow::upsertSearchAttributes` calls
roxblnfk May 21, 2023
f9c4dc7
Intercept `Workflow::await()` calls
roxblnfk May 21, 2023
5ec078c
Intercept `Workflow::awaitWithTimeout()` calls
roxblnfk May 21, 2023
6bffa28
Intercept `Workflow::complete()` calls
roxblnfk May 21, 2023
1360ca7
Merge pull request #305: update WorkflowOutboundCallsInterceptor, add…
roxblnfk May 22, 2023
d4eab96
Clean test interceptors; test ContinueAsNew command headers; test tha…
roxblnfk May 23, 2023
39dd4db
Split EncodedValues and Header classes
roxblnfk May 25, 2023
90eb63b
Fix type annotations; set converter to Header before pipeline runa an…
roxblnfk May 25, 2023
64530da
Add Header tests
roxblnfk May 25, 2023
12b8fac
Update Header and fix Header decoding
roxblnfk May 26, 2023
25d93c6
Fix PR review issues
roxblnfk May 31, 2023
9d8937f
Merge pull request #306: add interceptors
roxblnfk Jun 1, 2023
3c00c06
Mixed value in method Header::withValue (#312)
msmakouz Jun 14, 2023
b3610cc
Proto file: add history_length fields.
roxblnfk Jul 11, 2023
a1a382a
Merge branch 'master' into HEAD
roxblnfk Jul 11, 2023
2f2c224
Regenerate protocol message; fix types
roxblnfk Jul 11, 2023
bb9880e
Merge pull request #315: Add ability to get history length from Workf…
roxblnfk Jul 11, 2023
3a17811
Adding SystemInfoInterceptor (#320)
msmakouz Jul 11, 2023
097cf12
Adding RoadRunner version checker (#307)
msmakouz Jul 11, 2023
3c12a2d
Merge remote-tracking branch 'temporalio/2.6.0' into 2.7.0
roxblnfk Aug 10, 2023
693e431
Fix: replace `serializeToString` with `serializeToJsonString` in `Pro…
roxblnfk Aug 10, 2023
784056e
Merge branch 'master' into 2.7.0
roxblnfk Aug 16, 2023
a654a87
Fix version checker unit tests (#342)
msmakouz Aug 17, 2023
351514f
Merge branch 'master' into 2.7.0
roxblnfk Oct 5, 2023
25286ab
Get rid of unnecessary Header::setDataConverter() calls; mark the met…
roxblnfk Oct 9, 2023
9980fa6
Remove methods HeaderInterface::setDataConverter() and HeaderInterfac…
roxblnfk Oct 10, 2023
0f63cd2
Merge pull request #362: Header classes refactoring
roxblnfk Oct 12, 2023
f3c0a33
Add WorkflowClientCallsInterceptorTrait; fix signature of WorkflowOut…
roxblnfk Oct 16, 2023
28affbc
Transport Client now carries Workflow contexts instead of just info.
roxblnfk Oct 16, 2023
5ef06ca
Make all properties in interceptor configs readonly. Activity input: …
roxblnfk Oct 18, 2023
b5a52f0
Merge pull request #366: polishing and improvements interceptors
roxblnfk Oct 23, 2023
24c4fc7
Cleanup; prepare to PR interceptors into master branch
roxblnfk Oct 23, 2023
5f4f868
Merge branch 'master' into 2.7.0
roxblnfk Oct 23, 2023
3f5340c
Fix typos
roxblnfk Oct 23, 2023
647b6fa
Merge branch 'master' into 2.7.0
roxblnfk Nov 2, 2023
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"autoload-dev": {
"psr-4": {
"Temporal\\Tests\\": "tests",
"Temporal\\Tests\\Interceptor\\": "tests/Fixtures/src/Interceptor",
"Temporal\\Tests\\Workflow\\": "tests/Fixtures/src/Workflow",
"Temporal\\Tests\\Activity\\": "tests/Fixtures/src/Activity",
"Temporal\\Tests\\DTO\\": "tests/Fixtures/src/DTO",
Expand All @@ -92,7 +93,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
"dev-master": "2.7.x-dev"
}
},
"config": {
Expand Down
88 changes: 74 additions & 14 deletions src/Client/GRPC/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
namespace Temporal\Client\GRPC;

use Carbon\CarbonInterval;
use Closure;
use Exception;
use Grpc\UnaryCall;
use Temporal\Api\Workflowservice\V1\WorkflowServiceClient;
use Temporal\Exception\Client\ServiceClientException;
use Temporal\Exception\Client\TimeoutException;
use Temporal\Interceptor\GrpcClientInterceptor;
use Temporal\Internal\Interceptor\Pipeline;

abstract class BaseClient implements ServiceClientInterface
{
Expand All @@ -26,36 +30,35 @@
];
private WorkflowServiceClient $workflowService;

/** @var null|Closure(string $method, object $arg, ContextInterface $ctx): object */
private ?Closure $invokePipeline = null;

/** @var callable */
private $workflowServiceCloser;

/**
* @param WorkflowServiceClient $workflowService
*/
public function __construct(WorkflowServiceClient $workflowService)
{
$this->workflowService = $workflowService;
}

/**
* Close connection and destruct client.
*/
public function __destruct()
{
$this->close();
$this->workflowServiceCloser = $this->makeClientCloser($workflowService);
}

/**
* Close the communication channel associated with this stub.
*/
public function close(): void
{
$this->workflowService->close();
($this->workflowServiceCloser)();
}

/**
* @param string $address
* @return ServiceClientInterface
* @return static
* @psalm-suppress UndefinedClass
*/
public static function create(string $address): ServiceClientInterface
public static function create(string $address): static
{
$client = new WorkflowServiceClient(
$address,
Expand All @@ -71,7 +74,7 @@
* @param string|null $clientKey
* @param string|null $clientPem
* @param string|null $overrideServerName
* @return ServiceClientInterface
* @return static
*
* @psalm-suppress UndefinedClass
* @psalm-suppress UnusedVariable
Expand All @@ -82,8 +85,7 @@
string $clientKey = null,
string $clientPem = null,
string $overrideServerName = null
): ServiceClientInterface
{
): static {
$options = [
'credentials' => \Grpc\ChannelCredentials::createSsl(
\is_file($crt) ? \file_get_contents($crt) : null,
Expand All @@ -102,10 +104,25 @@
return new static($client);
}

/**
* @param null|Pipeline<GrpcClientInterceptor, object> $pipeline
*
* @return static
*/
final public function withInterceptorsPipeline(?Pipeline $pipeline): static
{
$clone = clone $this;
/** @see GrpcClientInterceptor::interceptCall() */
$callable = $pipeline?->with(Closure::fromCallable([$clone, 'call']), 'interceptCall');
$clone->invokePipeline = $callable === null ? null : Closure::fromCallable($callable);
return $clone;
}

/**
* @param non-empty-string $method RPC method name
* @param object $arg
* @param ContextInterface|null $ctx
*
* @return mixed
*
* @throw ClientException
Expand All @@ -114,6 +131,25 @@
{
$ctx = $ctx ?? Context::default();

return $this->invokePipeline !== null
? ($this->invokePipeline)($method, $arg, $ctx)
: $this->call($method, $arg, $ctx);
}

/**
* Call a gRPC method.
* Used in {@see withInterceptorsPipeline()}
*
* @param non-empty-string $method
* @param object $arg
* @param ContextInterface $ctx
*
* @return object
*
* @throws Exception
*/
private function call(string $method, object $arg, ContextInterface $ctx): object
{
$attempt = 0;
$retryOption = $ctx->getRetryOptions();

Expand All @@ -130,7 +166,7 @@
try {
$options = $ctx->getOptions();
if ($ctx->getDeadline() !== null) {
$diff = (new \DateTime())->diff($ctx->getDeadline());

Check failure on line 169 in src/Client/GRPC/BaseClient.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyNullArgument

src/Client/GRPC/BaseClient.php:169:53: PossiblyNullArgument: Argument 1 of DateTime::diff cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 169 in src/Client/GRPC/BaseClient.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyNullArgument

src/Client/GRPC/BaseClient.php:169:53: PossiblyNullArgument: Argument 1 of DateTime::diff cannot be null, possibly null value provided (see https://psalm.dev/078)
$options['timeout'] = CarbonInterval::instance($diff)->totalMicroseconds;
}

Expand All @@ -157,7 +193,7 @@
throw $e;
}

if ($ctx->getDeadline() !== null && $ctx->getDeadline()->getTimestamp() > time()) {

Check failure on line 196 in src/Client/GRPC/BaseClient.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyNullReference

src/Client/GRPC/BaseClient.php:196:74: PossiblyNullReference: Cannot call method getTimestamp on possibly null value (see https://psalm.dev/083)

Check failure on line 196 in src/Client/GRPC/BaseClient.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyNullReference

src/Client/GRPC/BaseClient.php:196:74: PossiblyNullReference: Cannot call method getTimestamp on possibly null value (see https://psalm.dev/083)
throw new TimeoutException('Call timeout has been reached');
}

Expand All @@ -174,4 +210,28 @@
}
} while (true);
}

/**
* Makes an object that will close workflow service client connection on parent class destruct.
*
* @param WorkflowServiceClient $workflowServiceClient
*
* @return callable
*/
private function makeClientCloser(WorkflowServiceClient $workflowServiceClient): callable
{
return new class ($workflowServiceClient) {
public function __construct(public WorkflowServiceClient $client) { }

public function __invoke(): void
{
$this->client->close();
}

public function __destruct()
{
$this->client->close();
}
};
}
}
16 changes: 15 additions & 1 deletion src/Client/GRPC/ServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* file that was distributed with this source code.
*/


namespace Temporal\Client\GRPC;

use Temporal\Api\Workflowservice\V1;
use Temporal\Client\ServerCapabilities;
use Temporal\Exception\Client\ServiceClientException;

class ServiceClient extends BaseClient
{
private ?ServerCapabilities $capabilities = null;

/**
* RegisterNamespace creates a new namespace which can be used as a container for
* all resources.
Expand Down Expand Up @@ -1037,5 +1039,17 @@ public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ContextI
{
return $this->invoke("ListBatchOperations", $arg, $ctx);
}

// todo Remove from autogenerated file
public function getServerCapabilities(): ?ServerCapabilities
{
return $this->capabilities;
}

// todo Remove from autogenerated file
public function setServerCapabilities(ServerCapabilities $capabilities): void
{
$this->capabilities = $capabilities;
}
Comment on lines +1042 to +1053
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved in a separated PR

}

64 changes: 64 additions & 0 deletions src/Client/Interceptor/SystemInfoInterceptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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\Client\Interceptor;

use Temporal\Api\Workflowservice\V1\GetSystemInfoRequest;
use Temporal\Client\GRPC\ContextInterface;
use Temporal\Client\GRPC\ServiceClient;
use Temporal\Client\GRPC\StatusCode;
use Temporal\Client\ServerCapabilities;
use Temporal\Exception\Client\ServiceClientException;
use Temporal\Interceptor\GrpcClientInterceptor;

/**
* @psalm-immutable
*/
final class SystemInfoInterceptor implements GrpcClientInterceptor
{
private bool $systemInfoRequested = false;

public function __construct(
private ServiceClient $serviceClient
) {
}

/**
* @param non-empty-string $method
* @param callable(non-empty-string, object, ContextInterface): object $next
*/
public function interceptCall(string $method, object $arg, ContextInterface $ctx, callable $next): object
{
if ($this->systemInfoRequested) {
return $next($method, $arg, $ctx);

Check failure on line 41 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureFunctionCall

src/Client/Interceptor/SystemInfoInterceptor.php:41:20: ImpureFunctionCall: Cannot call an impure function from a mutation-free context (see https://psalm.dev/202)

Check failure on line 41 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureFunctionCall

src/Client/Interceptor/SystemInfoInterceptor.php:41:20: ImpureFunctionCall: Cannot call an impure function from a mutation-free context (see https://psalm.dev/202)
}

try {
$systemInfo = $this->serviceClient->getSystemInfo(new GetSystemInfoRequest());

Check failure on line 45 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:45:49: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Client\GRPC\ServiceClient::getSystemInfo from a mutation-free context (see https://psalm.dev/203)

Check failure on line 45 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:45:49: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Client\GRPC\ServiceClient::getSystemInfo from a mutation-free context (see https://psalm.dev/203)

$capabilities = $systemInfo->getCapabilities();

Check failure on line 47 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:47:42: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse::getCapabilities from a mutation-free context (see https://psalm.dev/203)

Check failure on line 47 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:47:42: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse::getCapabilities from a mutation-free context (see https://psalm.dev/203)
if ($capabilities !== null && $this->serviceClient->getServerCapabilities() === null) {
$this->serviceClient->setServerCapabilities(new ServerCapabilities(

Check failure on line 49 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:49:39: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Client\GRPC\ServiceClient::setServerCapabilities from a mutation-free context (see https://psalm.dev/203)

Check failure on line 49 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:49:39: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Client\GRPC\ServiceClient::setServerCapabilities from a mutation-free context (see https://psalm.dev/203)
signalAndQueryHeader: $capabilities->getSignalAndQueryHeader(),

Check failure on line 50 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:50:58: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse\Capabilities::getSignalAndQueryHeader from a mutation-free context (see https://psalm.dev/203)

Check failure on line 50 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:50:58: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse\Capabilities::getSignalAndQueryHeader from a mutation-free context (see https://psalm.dev/203)
internalErrorDifferentiation: $capabilities->getInternalErrorDifferentiation()

Check failure on line 51 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:51:66: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse\Capabilities::getInternalErrorDifferentiation from a mutation-free context (see https://psalm.dev/203)

Check failure on line 51 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureMethodCall

src/Client/Interceptor/SystemInfoInterceptor.php:51:66: ImpureMethodCall: Cannot call a possibly-mutating method Temporal\Api\Workflowservice\V1\GetSystemInfoResponse\Capabilities::getInternalErrorDifferentiation from a mutation-free context (see https://psalm.dev/203)
));
}
} catch (ServiceClientException $e) {
if ($e->getCode() !== StatusCode::UNIMPLEMENTED) {
throw $e;
}
}

$this->systemInfoRequested = true;

Check failure on line 60 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

InaccessibleProperty

src/Client/Interceptor/SystemInfoInterceptor.php:60:9: InaccessibleProperty: Temporal\Client\Interceptor\SystemInfoInterceptor::$systemInfoRequested is marked readonly (see https://psalm.dev/054)

Check failure on line 60 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

InaccessibleProperty

src/Client/Interceptor/SystemInfoInterceptor.php:60:9: InaccessibleProperty: Temporal\Client\Interceptor\SystemInfoInterceptor::$systemInfoRequested is marked readonly (see https://psalm.dev/054)

return $next($method, $arg, $ctx);

Check failure on line 62 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureFunctionCall

src/Client/Interceptor/SystemInfoInterceptor.php:62:16: ImpureFunctionCall: Cannot call an impure function from a mutation-free context (see https://psalm.dev/202)

Check failure on line 62 in src/Client/Interceptor/SystemInfoInterceptor.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

ImpureFunctionCall

src/Client/Interceptor/SystemInfoInterceptor.php:62:16: ImpureFunctionCall: Cannot call an impure function from a mutation-free context (see https://psalm.dev/202)
}
}
40 changes: 40 additions & 0 deletions src/Client/ServerCapabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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\Client;

final class ServerCapabilities
{
public function __construct(
private bool $signalAndQueryHeader = false,
private bool $internalErrorDifferentiation = false
) {
}

/**
* True if signal and query headers are supported.
*/
public function isSignalAndQueryHeaderSupports(): bool
{
return $this->signalAndQueryHeader;
}

/**
* True if internal errors are differentiated from other types of errors for purposes of
* retrying non-internal errors.
* When unset/false, clients retry all failures. When true, clients should only retry
* non-internal errors.
*/
public function isInternalErrorDifferentiation(): bool
{
return $this->internalErrorDifferentiation;
}
}
Loading
Loading