Repository navigation
Temporal PHP SDK v2.21
Warning
#[MethodRetry] and #[CronSchedule] on a workflow method now apply to workflows started via WorkflowClient, not only to child workflows.
This release adds standalone activities, external payload storage, dynamic workflows and workflow cancellation reasons.
Features
Standalone Activities
ActivityClient starts activities without a workflow. The returned ActivityHandle can get the result, describe, cancel and terminate the execution.
use Temporal\Client\Activity\StartActivityOptions;
use Temporal\Client\ActivityClient;
use Temporal\Client\GRPC\ServiceClient;
$client = ActivityClient::create(ServiceClient::create('localhost:7233'));
$handle = $client->start(
'SendEmail',
StartActivityOptions::new()
->withId('send-email-42')
->withTaskQueue('emails')
->withStartToCloseTimeout(30),
'user@example.com',
);
$result = $handle->getResult();The server needs frontend.activityAPIsEnabled=true.
Closes #781.
External Payload Storage
PRs: #853, #871
Author: @xepozz
The client can offload large payloads to an external storage and keep only references in the workflow history.
The SDK ships an S3 driver (requires aws/aws-sdk-php):
use Aws\S3\S3Client;
use Temporal\Client\ClientOptions;
use Temporal\DataConverter\ExternalStorage\ExternalStorageOptions;
use Temporal\DataConverter\ExternalStorage\S3\AwsS3Client;
use Temporal\DataConverter\ExternalStorage\S3\S3StorageDriver;
$driver = new S3StorageDriver(new AwsS3Client(new S3Client(['region' => 'us-east-1'])), 'temporal-payloads');
$client = WorkflowClient::create(
ServiceClient::create('localhost:7233'),
(new ClientOptions())->withExternalStorage(new ExternalStorageOptions([$driver])),
);On the worker side, configure the temporal.external_storage section of RoadRunner 3.3+.
The API is experimental.
Dynamic Workflows
PR: #774
Author: @datashaman, @xepozz
A dynamic workflow handles every workflow type that is not registered on the worker (RoadRunner 3.0+):
#[WorkflowInterface]
final class PipelineWorkflow
{
#[WorkflowMethod(dynamic: true)]
public function handle(ValuesInterface $args)
{
$type = Workflow::getInfo()->type->name;
// ...
}
}Workflow Cancellation Reason
cancel() on a workflow stub and on an external workflow stub accepts a reason. The workflow gets it as the CanceledFailure message (RoadRunner 3.3+):
$stub->cancel('The order was closed');
// in the workflow
try {
yield Workflow::timer('1 hour');
} catch (CanceledFailure $e) {
$reason = $e->getOriginalMessage();
}Closes #567.
#[MethodRetry] and #[CronSchedule] for Client-Started Workflows
PR: #843
Author: @rela589n, @xepozz
WorkflowClient::newWorkflowStub() now applies #[MethodRetry] and #[CronSchedule] from the workflow method, like child workflows and the Java SDK do.
Values set in WorkflowOptions take precedence.
Others improvements and fixes
- #846 – fix(client):
getResult()returns the close event that arrives when the timeout runs out (@RaphaelFakhri) - #847 – fix: correct deadline handling of client calls and the test server start (@xepozz)
- #839 – Fix data converter assignment for update headers (@Sushisource)
- #860 – fix(client): map the Paused workflow execution status (@pcbeingused33)
- #862 – fix(client): keep leading zeros when converting protobuf timestamps (@pcbeingused33)
- #864 – fix: keep sub-second precision and long durations of protobuf times (@xepozz)
- #865 – fix(client): map run and task timeouts in describe() execution config (@xepozz)
- #867 – fix(worker): allow
Client::destroy()to release the queue (@xepozz) - #870 – fix(declaration): declare
getReflection()onNodeInterface(@xepozz) - #856 – fix(testing): skip non-archive assets in test server downloader (@algrvvv)
- #850 – feat: declare the Temporal skill source for llm/skills (@xepozz)
- #858 – fix(deps): raise grpc/grpc minimum to ^1.84.1 (@xepozz)
- #861 – chore: raise the minimum version of symfony/http-client to 6.4.51 (@xepozz)
- #854 – test: cover the versioning behavior of dynamic workflows (@xepozz)
New Contributors
- @RaphaelFakhri made their first contribution in #846
- @datashaman made their first contribution in #774
- @algrvvv made their first contribution in #856
- @pcbeingused33 made their first contribution in #860
- @rela589n made their first contribution in #843