Skip to content

Commit 40272bf

Browse files
authored
Merge pull request #650: Public Destroyable interface
2 parents 8dcc518 + bdf0c97 commit 40272bf

File tree

14 files changed

+80
-30
lines changed

14 files changed

+80
-30
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"google/common-protos": "^4.9",
2828
"google/protobuf": "^4.31.1",
2929
"grpc/grpc": "^1.57",
30+
"internal/destroy": "^1.0",
3031
"internal/promise": "^2.12",
3132
"nesbot/carbon": "^2.72.6 || ^3.8.4",
3233
"psr/log": "^2.0 || ^3.0.2",

psalm-baseline.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@
569569
<code><![CDATA[\IteratorAggregate]]></code>
570570
</MissingTemplateParam>
571571
</file>
572+
<file src="src/Internal/Declaration/Instance.php">
573+
<RedundantCondition>
574+
<code><![CDATA[isset($this->context)]]></code>
575+
</RedundantCondition>
576+
</file>
572577
<file src="src/Internal/Declaration/Instantiator/ActivityInstantiator.php">
573578
<InvalidDocblock>
574579
<code><![CDATA[final class ActivityInstantiator extends Instantiator]]></code>

src/Internal/Declaration/Destroyable.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Internal/Declaration/Instance.php

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

1212
namespace Temporal\Internal\Declaration;
1313

14+
use Internal\Destroy\Destroyable;
1415
use Temporal\Exception\InstantiationException;
1516
use Temporal\Internal\Declaration\Prototype\Prototype;
1617

@@ -46,6 +47,7 @@ public function getHandler(): MethodHandler
4647

4748
public function destroy(): void
4849
{
50+
isset($this->context) and $this->context instanceof Destroyable and $this->context->destroy();
4951
unset($this->handler, $this->context);
5052
}
5153

src/Internal/Declaration/WorkflowInstance/QueryDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace Temporal\Internal\Declaration\WorkflowInstance;
1313

14+
use Internal\Destroy\Destroyable;
1415
use Temporal\Api\Sdk\V1\WorkflowInteractionDefinition;
1516
use Temporal\DataConverter\ValuesInterface;
1617
use Temporal\Interceptor\WorkflowInbound\QueryInput;
17-
use Temporal\Internal\Declaration\Destroyable;
1818
use Temporal\Internal\Declaration\MethodHandler;
1919
use Temporal\Internal\Declaration\Prototype\QueryDefinition;
2020
use Temporal\Internal\Declaration\Prototype\WorkflowPrototype;

src/Internal/Declaration/WorkflowInstance/SignalDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Temporal\Internal\Declaration\WorkflowInstance;
1313

14+
use Internal\Destroy\Destroyable;
1415
use Temporal\Api\Sdk\V1\WorkflowInteractionDefinition;
1516
use Temporal\DataConverter\ValuesInterface;
16-
use Temporal\Internal\Declaration\Destroyable;
1717
use Temporal\Internal\Declaration\MethodHandler;
1818
use Temporal\Internal\Declaration\Prototype\SignalDefinition;
1919
use Temporal\Internal\Declaration\Prototype\WorkflowPrototype;

src/Internal/Declaration/WorkflowInstance/UpdateDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Temporal\Internal\Declaration\WorkflowInstance;
1313

14+
use Internal\Destroy\Destroyable;
1415
use React\Promise\Deferred;
1516
use React\Promise\PromiseInterface;
1617
use Temporal\Api\Sdk\V1\WorkflowInteractionDefinition;
1718
use Temporal\DataConverter\ValuesInterface;
1819
use Temporal\Interceptor\WorkflowInbound\UpdateInput;
19-
use Temporal\Internal\Declaration\Destroyable;
2020
use Temporal\Internal\Declaration\MethodHandler;
2121
use Temporal\Internal\Declaration\Prototype\UpdateDefinition;
2222
use Temporal\Internal\Declaration\Prototype\WorkflowPrototype;

src/Internal/Transport/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Temporal\Internal\Transport;
1313

14+
use Internal\Destroy\Destroyable;
1415
use React\Promise\PromiseInterface;
15-
use Temporal\Internal\Declaration\Destroyable;
1616
use Temporal\Worker\Transport\Command\CommandInterface;
1717
use Temporal\Worker\Transport\Command\RequestInterface;
1818
use Temporal\Worker\Transport\Command\ServerResponseInterface;

src/Internal/Workflow/Process/Scope.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Temporal\Internal\Workflow\Process;
1313

14+
use Internal\Destroy\Destroyable;
1415
use React\Promise\Deferred;
1516
use React\Promise\PromiseInterface;
1617
use Temporal\DataConverter\EncodedValues;
@@ -20,7 +21,6 @@
2021
use Temporal\Exception\Failure\TemporalFailure;
2122
use Temporal\Exception\InvalidArgumentException;
2223
use Temporal\Interceptor\WorkflowInbound\UpdateInput;
23-
use Temporal\Internal\Declaration\Destroyable;
2424
use Temporal\Internal\Declaration\MethodHandler;
2525
use Temporal\Internal\ServiceContainer;
2626
use Temporal\Internal\Transport\Request\Cancel;
@@ -296,6 +296,7 @@ public function destroy(): void
296296
$this->context?->destroy();
297297
$this->scopeContext?->destroy();
298298
unset(
299+
$this->coroutine,
299300
$this->context,
300301
$this->scopeContext,
301302
$this->deferred,

src/Internal/Workflow/WorkflowContext.php

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

1212
namespace Temporal\Internal\Workflow;
1313

14+
use Internal\Destroy\Destroyable;
1415
use Psr\Log\LoggerInterface;
1516
use Ramsey\Uuid\UuidInterface;
1617
use React\Promise\Deferred;
@@ -42,7 +43,6 @@
4243
use Temporal\Interceptor\WorkflowOutboundCalls\UpsertTypedSearchAttributesInput;
4344
use Temporal\Interceptor\WorkflowOutboundCallsInterceptor;
4445
use Temporal\Interceptor\WorkflowOutboundRequestInterceptor;
45-
use Temporal\Internal\Declaration\Destroyable;
4646
use Temporal\Internal\Declaration\EntityNameValidator;
4747
use Temporal\Internal\Declaration\WorkflowInstance\QueryDispatcher;
4848
use Temporal\Internal\Declaration\WorkflowInstance\SignalDispatcher;
@@ -701,10 +701,10 @@ public function destroy(): void
701701
{
702702
$this->awaits = [];
703703
$this->client->destroy();
704-
$this->workflowInstance->destroy();
705704
$this->queryDispatcher->destroy();
706705
$this->signalDispatcher->destroy();
707706
$this->updateDispatcher->destroy();
707+
$this->workflowInstance->destroy();
708708
unset($this->workflowInstance, $this->client);
709709
}
710710

0 commit comments

Comments
 (0)