diff --git a/README.md b/README.md index 5ca5a0f..4b7e0d0 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,8 @@ The following samples demonstrate much of the basic functionality and capabiliti - **[Signal](https://github.com/temporalio/samples-php/tree/master/app/src/Signal)**: Example of sending and handling a Signal +- **[Update](https://github.com/temporalio/samples-php/tree/master/app/src/Updates)**: Example of Workflow Update feature + - **[Saga](https://github.com/temporalio/samples-php/tree/master/app/src/Saga)**: Example of SAGA pattern support - **[SearchAttributes](https://github.com/temporalio/samples-php/tree/master/app/src/SearchAttributes)**: Example of Custom search attributes that can be used to find Workflows using predicates diff --git a/app/composer.json b/app/composer.json index 7d820c7..f7710d0 100644 --- a/app/composer.json +++ b/app/composer.json @@ -6,7 +6,8 @@ "spiral/tokenizer": "^3.7", "temporal/open-telemetry-interceptors": "dev-master", "open-telemetry/exporter-otlp": "^0.0.17", - "open-telemetry/transport-grpc": "^0.0.17" + "open-telemetry/transport-grpc": "^0.0.17", + "symfony/console": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "buggregator/trap": "^1.3" diff --git a/app/src/ActivityRetry/ExecuteCommand.php b/app/src/ActivityRetry/ExecuteCommand.php index 98b4133..7701c04 100644 --- a/app/src/ActivityRetry/ExecuteCommand.php +++ b/app/src/ActivityRetry/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'activity-retry'; protected const DESCRIPTION = 'Execute ActivityRetry\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/AsyncActivity/ExecuteCommand.php b/app/src/AsyncActivity/ExecuteCommand.php index 2fbed5c..e1f18ca 100644 --- a/app/src/AsyncActivity/ExecuteCommand.php +++ b/app/src/AsyncActivity/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'async-activity'; protected const DESCRIPTION = 'Execute AsyncActivity\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( AsyncGreetingWorkflowInterface::class, diff --git a/app/src/AsyncActivityCompletion/CompleteCommand.php b/app/src/AsyncActivityCompletion/CompleteCommand.php index 92160de..5524cd6 100644 --- a/app/src/AsyncActivityCompletion/CompleteCommand.php +++ b/app/src/AsyncActivityCompletion/CompleteCommand.php @@ -26,7 +26,7 @@ class CompleteCommand extends Command ['message', InputArgument::REQUIRED, 'Activity token'], ]; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { // @@@SNIPSTART samples-php-async-activity-completion-completebytoken $client = $this->workflowClient->newActivityCompletionClient(); diff --git a/app/src/AsyncActivityCompletion/ExecuteCommand.php b/app/src/AsyncActivityCompletion/ExecuteCommand.php index b59c42e..787ca30 100644 --- a/app/src/AsyncActivityCompletion/ExecuteCommand.php +++ b/app/src/AsyncActivityCompletion/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'user-activity:start'; protected const DESCRIPTION = 'Execute AsyncActivityCompletion\GreetingWorkflow and wait for user greeting'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/AsyncClosure/ExecuteCommand.php b/app/src/AsyncClosure/ExecuteCommand.php index 3949d27..e3b4b7d 100644 --- a/app/src/AsyncClosure/ExecuteCommand.php +++ b/app/src/AsyncClosure/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'async-closure'; protected const DESCRIPTION = 'Execute AsyncClosure\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( AsyncGreetingWorkflowInterface::class, diff --git a/app/src/BookingSaga/ExecuteCommand.php b/app/src/BookingSaga/ExecuteCommand.php index e0022fc..2bb8dc4 100644 --- a/app/src/BookingSaga/ExecuteCommand.php +++ b/app/src/BookingSaga/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'booking-saga'; protected const DESCRIPTION = 'Execute BookingSaga\TripBookingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( TripBookingWorkflowInterface::class, diff --git a/app/src/CancellationScope/ExecuteCommand.php b/app/src/CancellationScope/ExecuteCommand.php index 860ae56..2ee4637 100644 --- a/app/src/CancellationScope/ExecuteCommand.php +++ b/app/src/CancellationScope/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'cancellation-scope'; protected const DESCRIPTION = 'Execute CancellationScope\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/Child/ExecuteCommand.php b/app/src/Child/ExecuteCommand.php index 4904bbe..7c4df24 100644 --- a/app/src/Child/ExecuteCommand.php +++ b/app/src/Child/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'child'; protected const DESCRIPTION = 'Execute Child\ParentWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( ParentWorkflowInterface::class, diff --git a/app/src/Cron/ExecuteCommand.php b/app/src/Cron/ExecuteCommand.php index a9d90ff..97939c3 100644 --- a/app/src/Cron/ExecuteCommand.php +++ b/app/src/Cron/ExecuteCommand.php @@ -23,7 +23,7 @@ class ExecuteCommand extends Command protected const NAME = 'cron'; protected const DESCRIPTION = 'Start Cron\CronWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { // Sets the cron schedule using the WorkflowOptions. // The cron format is parsed by "https://github.com/robfig/cron" library. diff --git a/app/src/Exception/ExecuteCommand.php b/app/src/Exception/ExecuteCommand.php index b16729b..9d7c3d8 100644 --- a/app/src/Exception/ExecuteCommand.php +++ b/app/src/Exception/ExecuteCommand.php @@ -23,7 +23,7 @@ class ExecuteCommand extends Command protected const NAME = 'exception'; protected const DESCRIPTION = 'Execute Exception\FailedWorkflow with multiple signals'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( FailedWorkflow::class, diff --git a/app/src/FileProcessing/ExecuteCommand.php b/app/src/FileProcessing/ExecuteCommand.php index 72761c1..feeda6e 100644 --- a/app/src/FileProcessing/ExecuteCommand.php +++ b/app/src/FileProcessing/ExecuteCommand.php @@ -28,7 +28,7 @@ class ExecuteCommand extends Command ['url', InputArgument::REQUIRED, 'Download URL'] ]; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( FileProcessingWorkflowInterface::class, diff --git a/app/src/Interceptors/ExecuteCommand.php b/app/src/Interceptors/ExecuteCommand.php index b1ca0ff..7e9003f 100644 --- a/app/src/Interceptors/ExecuteCommand.php +++ b/app/src/Interceptors/ExecuteCommand.php @@ -23,7 +23,7 @@ class ExecuteCommand extends Command protected const NAME = 'interceptors'; protected const DESCRIPTION = 'Execute workflow with interceptors'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( TestActivityAttributesInterceptor::class, diff --git a/app/src/LocalActivity/ExecuteCommand.php b/app/src/LocalActivity/ExecuteCommand.php index a07eade..a7609b8 100644 --- a/app/src/LocalActivity/ExecuteCommand.php +++ b/app/src/LocalActivity/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'local-activity'; protected const DESCRIPTION = 'Execute LocalActivity\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/MoneyBatch/ExecuteCommand.php b/app/src/MoneyBatch/ExecuteCommand.php index 744aef1..1dc8148 100644 --- a/app/src/MoneyBatch/ExecuteCommand.php +++ b/app/src/MoneyBatch/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'money-batch'; protected const DESCRIPTION = 'Execute MoneyBatch\MoneyBatchWorkflow with multiple signals and queries'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( MoneyBatchWorkflowInterface::class, diff --git a/app/src/MoneyTransfer/ExecuteCommand.php b/app/src/MoneyTransfer/ExecuteCommand.php index 86fe832..a144631 100644 --- a/app/src/MoneyTransfer/ExecuteCommand.php +++ b/app/src/MoneyTransfer/ExecuteCommand.php @@ -20,7 +20,7 @@ class ExecuteCommand extends Command protected const NAME = 'money-transfer'; protected const DESCRIPTION = 'Execute MoneyTransferWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub(AccountTransferWorkflowInterface::class); $output->writeln("Starting MoneyTransferWorkflow... "); diff --git a/app/src/Periodic/ExecuteCommand.php b/app/src/Periodic/ExecuteCommand.php index 28e3dca..05d7a48 100644 --- a/app/src/Periodic/ExecuteCommand.php +++ b/app/src/Periodic/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'periodic:start'; protected const DESCRIPTION = 'Start Periodic\PeriodicWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( PeriodicWorkflowInterface::class, diff --git a/app/src/Periodic/StopCommand.php b/app/src/Periodic/StopCommand.php index 69569ba..65dc6b0 100644 --- a/app/src/Periodic/StopCommand.php +++ b/app/src/Periodic/StopCommand.php @@ -20,7 +20,7 @@ class StopCommand extends Command protected const NAME = 'periodic:stop'; protected const DESCRIPTION = 'Stop Periodic\PeriodicWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newUntypedRunningWorkflowStub( PeriodicWorkflowInterface::WORKFLOW_ID diff --git a/app/src/PolymorphicActivity/ExecuteCommand.php b/app/src/PolymorphicActivity/ExecuteCommand.php index 52002de..bfa0507 100644 --- a/app/src/PolymorphicActivity/ExecuteCommand.php +++ b/app/src/PolymorphicActivity/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'polymorphic'; protected const DESCRIPTION = 'Execute PolymorphicActivity\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/Query/ExecuteCommand.php b/app/src/Query/ExecuteCommand.php index c28ba97..dc9522f 100644 --- a/app/src/Query/ExecuteCommand.php +++ b/app/src/Query/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'query'; protected const DESCRIPTION = 'Execute Query\QueryWorkflow with additional query and timer'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( QueryWorkflowInterface::class, diff --git a/app/src/Replay/ExecuteCommand.php b/app/src/Replay/ExecuteCommand.php index c8df2d5..02d9dae 100644 --- a/app/src/Replay/ExecuteCommand.php +++ b/app/src/Replay/ExecuteCommand.php @@ -30,7 +30,7 @@ class ExecuteCommand extends Command ]; protected const DESCRIPTION = 'Replay workflow executions from history events'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $replayer = new WorkflowReplayer(); $workflowType = $input->getArgument('workflow-type'); diff --git a/app/src/Saga/ExecuteCommand.php b/app/src/Saga/ExecuteCommand.php index ac630a5..b199bd8 100644 --- a/app/src/Saga/ExecuteCommand.php +++ b/app/src/Saga/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'saga'; protected const DESCRIPTION = 'Execute Saga\SagaWorkflow with multiple signals'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( SagaWorkflowInterface::class, diff --git a/app/src/Schedule/CreateCommand.php b/app/src/Schedule/CreateCommand.php index 714271a..89e5077 100644 --- a/app/src/Schedule/CreateCommand.php +++ b/app/src/Schedule/CreateCommand.php @@ -34,7 +34,7 @@ class CreateCommand extends Command ]; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $specInit = $spec = Schedule\Spec\ScheduleSpec::new() ->withJitter('10m'); diff --git a/app/src/Schedule/DeleteCommand.php b/app/src/Schedule/DeleteCommand.php index 10c16a5..9b534d9 100644 --- a/app/src/Schedule/DeleteCommand.php +++ b/app/src/Schedule/DeleteCommand.php @@ -23,7 +23,7 @@ class DeleteCommand extends Command protected const NAME = 'schedule:delete'; protected const DESCRIPTION = 'Delete scheduled workflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $handle = $this->scheduleClient->getHandle(ScheduleWorkflowInterface::SCHEDULE_ID); diff --git a/app/src/Schedule/DescribeCommand.php b/app/src/Schedule/DescribeCommand.php index ab2839c..703c128 100644 --- a/app/src/Schedule/DescribeCommand.php +++ b/app/src/Schedule/DescribeCommand.php @@ -21,7 +21,7 @@ class DescribeCommand extends Command protected const NAME = 'schedule:describe'; protected const DESCRIPTION = 'Describe the Schedule'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $handle = $this->scheduleClient->getHandle(ScheduleWorkflowInterface::SCHEDULE_ID); diff --git a/app/src/Schedule/ListCommand.php b/app/src/Schedule/ListCommand.php index b574bae..729dd30 100644 --- a/app/src/Schedule/ListCommand.php +++ b/app/src/Schedule/ListCommand.php @@ -21,7 +21,7 @@ class ListCommand extends Command protected const NAME = 'schedule:list'; protected const DESCRIPTION = 'List all Schedules'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $schedules = $this->scheduleClient->listSchedules(); diff --git a/app/src/SearchAttributes/ExecuteCommand.php b/app/src/SearchAttributes/ExecuteCommand.php index f052a69..9512fb6 100644 --- a/app/src/SearchAttributes/ExecuteCommand.php +++ b/app/src/SearchAttributes/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'search-attributes'; protected const DESCRIPTION = 'Execute SearchAttributes\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/Signal/ExecuteCommand.php b/app/src/Signal/ExecuteCommand.php index ba61181..5a4fc0c 100644 --- a/app/src/Signal/ExecuteCommand.php +++ b/app/src/Signal/ExecuteCommand.php @@ -22,7 +22,7 @@ class ExecuteCommand extends Command protected const NAME = 'signal'; protected const DESCRIPTION = 'Execute Signal\SignalWorkflow with multiple signals'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( SignalWorkflowInterface::class, diff --git a/app/src/SimpleActivity/ExecuteCommand.php b/app/src/SimpleActivity/ExecuteCommand.php index 369ec88..bc2eab2 100644 --- a/app/src/SimpleActivity/ExecuteCommand.php +++ b/app/src/SimpleActivity/ExecuteCommand.php @@ -23,7 +23,7 @@ class ExecuteCommand extends Command protected const NAME = 'simple-activity'; protected const DESCRIPTION = 'Execute SimpleActivity\GreetingWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( GreetingWorkflowInterface::class, diff --git a/app/src/Subscription/CancelCommand.php b/app/src/Subscription/CancelCommand.php index e0d9989..c8446a2 100644 --- a/app/src/Subscription/CancelCommand.php +++ b/app/src/Subscription/CancelCommand.php @@ -28,7 +28,7 @@ class CancelCommand extends Command ['userID', InputArgument::REQUIRED, 'Unique user ID'] ]; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $userID = $input->getArgument('userID'); diff --git a/app/src/Subscription/SubscribeCommand.php b/app/src/Subscription/SubscribeCommand.php index 9faa3d5..290c8bb 100644 --- a/app/src/Subscription/SubscribeCommand.php +++ b/app/src/Subscription/SubscribeCommand.php @@ -29,7 +29,7 @@ class SubscribeCommand extends Command ['userID', InputArgument::REQUIRED, 'Unique user ID'] ]; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $userID = $input->getArgument('userID'); diff --git a/app/src/UpdatableTimer/ExecuteCommand.php b/app/src/UpdatableTimer/ExecuteCommand.php index ab4aa1d..af21bf8 100644 --- a/app/src/UpdatableTimer/ExecuteCommand.php +++ b/app/src/UpdatableTimer/ExecuteCommand.php @@ -24,7 +24,7 @@ class ExecuteCommand extends Command protected const NAME = 'updatable-timer:start'; protected const DESCRIPTION = 'Execute UpdatableTimer\DynamicSleepWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newWorkflowStub( DynamicSleepWorkflowInterface::class, diff --git a/app/src/UpdatableTimer/ProlongCommand.php b/app/src/UpdatableTimer/ProlongCommand.php index fca70b1..53d06fc 100644 --- a/app/src/UpdatableTimer/ProlongCommand.php +++ b/app/src/UpdatableTimer/ProlongCommand.php @@ -20,7 +20,7 @@ class ProlongCommand extends Command protected const NAME = 'updatable-timer:prolong'; protected const DESCRIPTION = 'Prolong the duration of UpdatableTimer\DynamicSleepWorkflow'; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $workflow = $this->workflowClient->newRunningWorkflowStub( DynamicSleepWorkflowInterface::class, diff --git a/app/src/Updates/ExecuteCommand.php b/app/src/Updates/ExecuteCommand.php index 9e3a717..8c193e6 100644 --- a/app/src/Updates/ExecuteCommand.php +++ b/app/src/Updates/ExecuteCommand.php @@ -38,7 +38,7 @@ class ExecuteCommand extends Command private InputInterface $input; private OutputInterface $output; - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; $this->output = $output;