Skip to content

Commit df5ab28

Browse files
committed
Merge remote-tracking branch 'origin/master' into context-instance
2 parents b269fbc + 168cc99 commit df5ab28

File tree

24 files changed

+327
-186
lines changed

24 files changed

+327
-186
lines changed

.github/workflows/run-test-suite.yml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
extensions-suffix: [ '', ', protobuf' ]
5454
dependencies: [ lowest , highest ]
5555
include:
56+
# Add Windows
5657
- os: windows-latest
5758
extensions-suffix: ', protobuf'
5859
php: 8.1
@@ -63,71 +64,32 @@ jobs:
6364
git config --global core.autocrlf false
6465
git config --global core.eol lf
6566
67+
- name: Check Out Code
68+
uses: actions/checkout@v4
69+
6670
- name: Setup PHP ${{ matrix.php }}
6771
uses: shivammathur/setup-php@v2
6872
with:
6973
php-version: ${{ matrix.php }}
70-
tools: composer:v2
7174
extensions: dom, sockets, grpc, curl ${{ matrix.extensions-suffix }}
72-
# extensions: dom, sockets, grpc, curl
73-
74-
- name: Check Out Code
75-
uses: actions/checkout@v4
76-
with:
77-
fetch-depth: 1
7875

7976
- name: Validate composer.json and composer.lock
8077
run: composer validate --strict
8178

82-
- name: Download CPX (PHP 8.4)
83-
if: inputs.download-binaries == true && matrix.php == '8.4'
84-
run: composer global require cpx/cpx
85-
86-
- name: Get Composer Cache Directory
87-
id: composer-cache
88-
run: |
89-
echo "::set-output name=dir::$(composer config cache-files-dir)"
90-
91-
- name: Cache Composer Dependencies
92-
uses: actions/cache@v3
79+
- name: Install dependencies with composer
80+
uses: ramsey/composer-install@v3
9381
with:
94-
path: ${{ steps.composer-cache.outputs.dir }}
95-
key: php-${{ matrix.php }}-${{ matrix.os }}-composer-${{ hashFiles('**/composer.lock') }}
96-
restore-keys: |
97-
php-${{ matrix.php }}-${{ matrix.os }}-composer-
98-
99-
- name: Install lowest dependencies from composer.json
100-
if: matrix.dependencies == 'lowest' && matrix.php != '8.4'
101-
run: composer update --no-interaction --no-progress --prefer-lowest
102-
103-
- name: Install lowest dependencies from composer.json ignoring ext-php constraint (PHP 8.4)
104-
if: matrix.dependencies == 'lowest' && matrix.php == '8.4'
105-
run: composer update --no-interaction --no-progress --prefer-lowest --ignore-platform-req php
106-
82+
dependency-versions: ${{ matrix.dependencies }}
10783

10884
- name: Validate lowest dependencies
10985
if: matrix.dependencies == 'lowest' && matrix.php == '8.1'
11086
env:
11187
COMPOSER_POOL_OPTIMIZER: 0
11288
run: vendor/bin/validate-prefer-lowest
11389

114-
115-
- name: Install highest dependencies from composer.json
116-
if: matrix.dependencies == 'highest' && matrix.php != '8.4'
117-
run: composer update --no-interaction --no-progress
118-
119-
- name: Install highest dependencies from composer.json ignoring ext-php constraint (PHP 8.4)
120-
if: matrix.dependencies == 'highest' && matrix.php == '8.4'
121-
run: composer update --no-interaction --no-progress --ignore-platform-req php
122-
123-
12490
- name: Download binaries
125-
if: inputs.download-binaries == true && matrix.php != '8.4'
91+
if: inputs.download-binaries == true
12692
run: composer get:binaries
12793

128-
- name: Download binaries (PHP 8.4)
129-
if: inputs.download-binaries == true && matrix.php == '8.4'
130-
run: cpx internal/dload get --no-interaction
131-
13294
- name: Run tests
13395
run: ${{ inputs.test-command }}

.github/workflows/security-check.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,11 @@ jobs:
2525

2626
- name: Check Out Code
2727
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 1
30-
31-
- name: Get Composer Cache Directory
32-
id: composer-cache
33-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3428

35-
- name: Cache Dependencies
36-
uses: actions/cache@v3
29+
- name: Install dependencies with composer
30+
uses: ramsey/composer-install@v3
3731
with:
38-
path: ${{ steps.composer-cache.outputs.dir }}
39-
key: php-${{ matrix.php }}-${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40-
restore-keys: php-${{ matrix.php }}-${{ runner.os }}-composer-
41-
42-
- name: Install Composer Dependencies
43-
run: composer install --prefer-dist --no-interaction
32+
dependency-versions: ${{ matrix.dependencies }}
4433

4534
- name: Verify
4635
run: composer require --dev roave/security-advisories:dev-latest

.github/workflows/static-analysis.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,11 @@ jobs:
2525

2626
- name: Check Out Code
2727
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 1
30-
31-
- name: Get Composer Cache Directory
32-
id: composer-cache
33-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3428

35-
- name: Cache Dependencies
36-
uses: actions/cache@v3
29+
- name: Install dependencies with composer
30+
uses: ramsey/composer-install@v3
3731
with:
38-
path: ${{ steps.composer-cache.outputs.dir }}
39-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40-
restore-keys: php-${{ matrix.php }}-${{ runner.os }}-composer-
41-
42-
- name: Install Composer Dependencies
43-
run: composer install --prefer-dist --no-interaction
32+
dependency-versions: ${{ matrix.dependencies }}
4433

4534
- name: 🔍 Run Tests
4635
run: vendor/bin/psalm
@@ -66,19 +55,10 @@ jobs:
6655
with:
6756
fetch-depth: 1
6857

69-
- name: Get Composer Cache Directory
70-
id: composer-cache
71-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
72-
73-
- name: Cache Dependencies
74-
uses: actions/cache@v3
58+
- name: Install dependencies with composer
59+
uses: ramsey/composer-install@v3
7560
with:
76-
path: ${{ steps.composer-cache.outputs.dir }}
77-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
78-
restore-keys: php-${{ matrix.php }}-${{ runner.os }}-composer-
79-
80-
- name: Install Composer Dependencies
81-
run: composer install --prefer-dist --no-interaction
61+
dependency-versions: ${{ matrix.dependencies }}
8262

8363
- name: 🔍 Run Tests
8464
run: composer test:arch

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"composer/composer": "^2.8.4",
5757
"dereuromark/composer-prefer-lowest": "^0.1.10",
5858
"doctrine/annotations": "^1.14.4 || ^2.0.2",
59-
"internal/dload": "^1.0",
59+
"internal/dload": "^1.0.2",
6060
"jetbrains/phpstorm-attributes": "dev-master",
6161
"laminas/laminas-code": "^4.16",
6262
"phpunit/phpunit": "^10.5.41",
@@ -82,8 +82,10 @@
8282
"buggregator/trap": "For better debugging"
8383
},
8484
"scripts": {
85-
"post-update-cmd": "Temporal\\Worker\\Transport\\RoadRunnerVersionChecker::postUpdate",
86-
"get:binaries": "dload get --no-interaction -vv",
85+
"get:binaries": [
86+
"dload get --no-interaction -vv",
87+
"Temporal\\Worker\\Transport\\RoadRunnerVersionChecker::postUpdate"
88+
],
8789
"cs:diff": "php-cs-fixer fix --dry-run -v --diff --show-progress dots",
8890
"cs:fix": "php-cs-fixer fix -v",
8991
"psalm": "psalm",

dload.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?xml version="1.0"?>
2-
<dload>
2+
<dload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/internal/dload/dload.xsd"
4+
temp-dir="./runtime"
5+
>
36
<actions>
4-
<download software="rr" version="^2024.2"/>
7+
<download software="rr" version="^2024.3.3"/>
58
<download software="temporal"/>
69
<download software="temporal-tests-server"/>
710
</actions>
811
<registry>
912
<software name="Temporal Tests Server" alias="temporal-tests-server">
1013
<repository type="github" uri="temporalio/sdk-java" asset-pattern="/^temporal-test-server.*/"/>
11-
<file pattern="/^(temporal-test-server)(?:\.exe)?$/" />
14+
<binary name="temporal-test-server"/>
1215
</software>
1316
</registry>
1417
</dload>

psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@
135135
<code><![CDATA[$options->namespace]]></code>
136136
</DeprecatedProperty>
137137
</file>
138-
<file src="src/Client/Update/UpdateHandle.php">
139-
<PossiblyNullArgument>
140-
<code><![CDATA[$result->getSuccess()]]></code>
141-
</PossiblyNullArgument>
142-
</file>
143138
<file src="src/Client/WorkflowClient.php">
144139
<ArgumentTypeCoercion>
145140
<code><![CDATA[$counter]]></code>
@@ -1481,7 +1476,6 @@
14811476
<code><![CDATA[$codec]]></code>
14821477
</PropertyNotSetInConstructor>
14831478
<UndefinedInterfaceMethod>
1484-
<code><![CDATA[dispatch]]></code>
14851479
<code><![CDATA[dispatch]]></code>
14861480
<code><![CDATA[dispatch]]></code>
14871481
<code><![CDATA[update]]></code>

src/Client/Update/UpdateHandle.php

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,38 @@ private function fetchResult(int|float|null $timeout = null): void
114114
(new \Temporal\Api\Update\V1\WaitPolicy())->setLifecycleStage(LifecycleStage::StageCompleted->value),
115115
);
116116

117-
try {
118-
$response = $this->client->PollWorkflowExecutionUpdate(
119-
$request,
120-
$timeout === null ? null : $this->client->getContext()->withTimeout($timeout),
121-
);
122-
} catch (TimeoutException|CanceledException $e) {
123-
throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e);
124-
}
125117

126-
// Workflow Uprate accepted
127-
$result = $response->getOutcome();
128-
\assert($result !== null);
118+
$context = $timeout === null
119+
? $this->client->getContext()
120+
: $this->client->getContext()->withTimeout($timeout);
121+
$deadline = $context->getDeadline();
122+
123+
// Convert request timeout into deadline
124+
$deadline === null or $context = $context->withDeadline($deadline);
125+
126+
do {
127+
try {
128+
$response = $this->client->PollWorkflowExecutionUpdate($request, $context);
129+
} catch (TimeoutException|CanceledException $e) {
130+
throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e);
131+
}
132+
133+
// Workflow Uprate accepted
134+
$result = $response->getOutcome();
135+
136+
/**
137+
* Retry the request.
138+
*
139+
* TimeoutException will be thrown in {@see \Temporal\Client\GRPC\BaseClient::call()} method
140+
* because the deadline is provided in the context.
141+
* That's why the deadline condition is not checked here.
142+
*/
143+
} while ($result === null);
129144

130145
// Accepted with result
131-
if ($result->getSuccess() !== null) {
132-
$this->result = EncodedValues::fromPayloads($result->getSuccess(), $this->converter);
146+
$success = $result->getSuccess();
147+
if ($success !== null) {
148+
$this->result = EncodedValues::fromPayloads($success, $this->converter);
133149
return;
134150
}
135151

src/Client/Workflow/WorkflowExecutionDescription.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* DTO that contains detailed information about Workflow Execution.
1212
*
1313
* @see \Temporal\Api\Workflowservice\V1\DescribeWorkflowExecutionResponse
14-
*
15-
* @internal
1614
*/
1715
final class WorkflowExecutionDescription
1816
{

src/Exception/Failure/FailureConverter.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Temporal\Exception\Failure;
1313

14-
use Psr\Log\LoggerInterface;
1514
use Temporal\Api\Common\V1\ActivityType;
1615
use Temporal\Api\Common\V1\WorkflowExecution;
1716
use Temporal\Api\Common\V1\WorkflowType;
@@ -30,8 +29,6 @@
3029

3130
final class FailureConverter
3231
{
33-
private static ?LoggerInterface $logger;
34-
3532
public static function mapFailureToException(Failure $failure, DataConverterInterface $converter): TemporalFailure
3633
{
3734
$e = self::createFailureException($failure, $converter);
@@ -160,11 +157,6 @@ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterfa
160157
return $failure;
161158
}
162159

163-
public function setLogger(LoggerInterface $logger): void
164-
{
165-
self::$logger = $logger;
166-
}
167-
168160
private static function createFailureException(Failure $failure, DataConverterInterface $converter): TemporalFailure
169161
{
170162
$previous = null;

src/Internal/Transport/Client.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public function reject(CommandInterface $command, \Throwable $reason): void
116116
$this->fetch($command->getID())->reject($reason);
117117
}
118118

119+
public function fork(): ClientInterface
120+
{
121+
return new DetachedClient($this, function (array $ids): void {
122+
foreach ($ids as $id) {
123+
unset($this->requests[$id]);
124+
}
125+
});
126+
}
127+
128+
public function destroy(): void
129+
{
130+
$this->requests = [];
131+
unset($this->queue);
132+
}
133+
119134
private function fetch(int $id): Deferred
120135
{
121136
$request = $this->get($id);

0 commit comments

Comments
 (0)