diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 77291bae..da71025b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -728,16 +728,12 @@ header?->setDataConverter($this->converter)]]> input?->setDataConverter($this->converter)]]> - input?->setDataConverter($this->converter)]]> - input?->toPayloads()]]> memo?->setDataConverter($this->converter)]]> searchAttributes?->setDataConverter($this->converter)]]> header]]> input]]> - input]]> - input]]> memo]]> searchAttributes]]> diff --git a/src/Common/RetryOptions.php b/src/Common/RetryOptions.php index 81f7a85d..71b52c1c 100644 --- a/src/Common/RetryOptions.php +++ b/src/Common/RetryOptions.php @@ -34,6 +34,7 @@ * @psalm-type ExceptionsList = array> * @psalm-import-type DateIntervalValue from DateInterval * @psalm-immutable + * @see RetryPolicy */ class RetryOptions extends Options { diff --git a/src/Internal/Mapper/ScheduleMapper.php b/src/Internal/Mapper/ScheduleMapper.php index 07098baf..b189ef96 100644 --- a/src/Internal/Mapper/ScheduleMapper.php +++ b/src/Internal/Mapper/ScheduleMapper.php @@ -50,6 +50,9 @@ public function toMessage(Schedule $dto): \Temporal\Api\Schedule\V1\Schedule return new \Temporal\Api\Schedule\V1\Schedule($array); } + /** + * @psalm-suppress TypeDoesNotContainNull,RedundantCondition + */ private function prepareAction(ScheduleAction $action, array $array): \Temporal\Api\Schedule\V1\ScheduleAction { $result = new \Temporal\Api\Schedule\V1\ScheduleAction(); @@ -64,7 +67,7 @@ private function prepareAction(ScheduleAction $action, array $array): \Temporal\ $action->input?->setDataConverter($this->converter); $values['input'] = $action->input?->toPayloads() ?? new Payloads(); $values['workflow_id_reuse_policy'] = $action->workflowIdReusePolicy->value; - $values['retry_policy'] = new RetryPolicy($values['retry_policy'] ?? []); + $values['retry_policy'] = $action->retryPolicy?->toWorkflowRetryPolicy(); $result->setStartWorkflow( new \Temporal\Api\Workflow\V1\NewWorkflowExecutionInfo($values), diff --git a/tests/Unit/Schedule/Mapper/WorkflowExecutionInfoMapperTest.php b/tests/Unit/Schedule/Mapper/WorkflowExecutionInfoMapperTest.php index c14a4c73..2a3177af 100644 --- a/tests/Unit/Schedule/Mapper/WorkflowExecutionInfoMapperTest.php +++ b/tests/Unit/Schedule/Mapper/WorkflowExecutionInfoMapperTest.php @@ -41,7 +41,11 @@ public function testFromPayload(): void Schedule\Action\StartWorkflowAction::new('PingSite') ->withInput(['google.com']) ->withTaskQueue('default') - ->withRetryPolicy(RetryOptions::new()->withMaximumAttempts(3)) + ->withRetryPolicy(RetryOptions::new() + ->withMaximumAttempts(3) + ->withInitialInterval(\Carbon\CarbonInterval::seconds(10)) + ->withMaximumInterval(\Carbon\CarbonInterval::seconds(20)) + ) ->withHeader(['foo' => 'bar']) ->withWorkflowExecutionTimeout('40m') ->withWorkflowRunTimeout('30m') @@ -96,6 +100,11 @@ public function testFromPayload(): void $this->assertInstanceOf(NewWorkflowExecutionInfo::class, $startWorkflow); $this->assertSame('PingSite', $startWorkflow->getWorkflowType()->getName()); $this->assertSame('default', $startWorkflow->getTaskQueue()->getName()); + // Retry Policy + $this->assertSame(3, $startWorkflow->getRetryPolicy()->getMaximumAttempts()); + $this->assertSame(10, $startWorkflow->getRetryPolicy()->getInitialInterval()->getSeconds()); + $this->assertSame(20, $startWorkflow->getRetryPolicy()->getMaximumInterval()->getSeconds()); + // Header $this->assertSame( ['foo' => 'bar'], EncodedCollection::fromPayloadCollection(