@@ -316,14 +316,6 @@ private function configureExecutionRequest(
316316 StartInput $ input ,
317317 ): StartWorkflowExecutionRequest |SignalWithStartWorkflowExecutionRequest {
318318 $ options = $ input ->options ;
319- $ header = $ input ->header ;
320-
321- \assert ($ header instanceof Header);
322- $ header ->setDataConverter ($ this ->converter );
323-
324- $ metadata = (new UserMetadata ())
325- ->setSummary ($ this ->converter ->toPayload ($ options ->staticSummary ))
326- ->setDetails ($ this ->converter ->toPayload ($ options ->staticDetails ));
327319
328320 $ req ->setRequestId (Uuid::v4 ())
329321 ->setIdentity ($ this ->clientOptions ->identity )
@@ -332,22 +324,43 @@ private function configureExecutionRequest(
332324 ->setWorkflowType (new WorkflowType (['name ' => $ input ->workflowType ]))
333325 ->setWorkflowId ($ input ->workflowId )
334326 ->setCronSchedule ($ options ->cronSchedule ?? '' )
335- ->setRetryPolicy ($ options ->retryOptions ? $ options ->retryOptions ->toWorkflowRetryPolicy () : null )
336327 ->setWorkflowIdReusePolicy ($ options ->workflowIdReusePolicy )
337328 ->setWorkflowIdConflictPolicy ($ options ->workflowIdConflictPolicy ->value )
338329 ->setWorkflowRunTimeout (DateInterval::toDuration ($ options ->workflowRunTimeout ))
339330 ->setWorkflowExecutionTimeout (DateInterval::toDuration ($ options ->workflowExecutionTimeout ))
340- ->setWorkflowTaskTimeout (DateInterval::toDuration ($ options ->workflowTaskTimeout ))
341- ->setMemo ($ options ->toMemo ($ this ->converter ))
342- ->setSearchAttributes ($ options ->toSearchAttributes ($ this ->converter ))
343- ->setHeader ($ header ->toHeader ())
344- ->setUserMetadata ($ metadata );
345-
346- $ delay = DateInterval::toDuration ($ options ->workflowStartDelay );
347- if ($ delay !== null && ($ delay ->getSeconds () > 0 || $ delay ->getNanos () > 0 )) {
348- $ req ->setWorkflowStartDelay ($ delay );
331+ ->setWorkflowTaskTimeout (DateInterval::toDuration ($ options ->workflowTaskTimeout ));
332+
333+ // Retry Policy
334+ $ options ->retryOptions === null or $ req ->setRetryPolicy ($ options ->retryOptions ->toWorkflowRetryPolicy ());
335+
336+ // Memo
337+ $ memo = $ options ->toMemo ($ this ->converter );
338+ $ memo === null or $ req ->setMemo ($ memo );
339+
340+ // Search Attributes
341+ $ searchAttributes = $ options ->toSearchAttributes ($ this ->converter );
342+ $ searchAttributes === null or $ req ->setSearchAttributes ($ searchAttributes );
343+
344+ // Header
345+ $ header = $ input ->header ;
346+ \assert ($ header instanceof Header);
347+ if ($ header ->count () > 0 ) {
348+ $ header ->setDataConverter ($ this ->converter );
349+ $ req ->setHeader ($ header ->toHeader ());
349350 }
350351
352+ // User metadata
353+ if ($ options ->staticSummary !== '' || $ options ->staticDetails !== '' ) {
354+ $ metadata = (new UserMetadata ());
355+ $ options ->staticSummary === '' or $ metadata ->setSummary ($ this ->converter ->toPayload ($ options ->staticSummary ));
356+ $ options ->staticDetails === '' or $ metadata ->setDetails ($ this ->converter ->toPayload ($ options ->staticDetails ));
357+ $ req ->setUserMetadata ($ metadata );
358+ }
359+
360+ // Start Delay
361+ $ delay = DateInterval::toDuration ($ options ->workflowStartDelay , true );
362+ $ delay === null or $ req ->setWorkflowStartDelay ($ delay );
363+
351364 if ($ req instanceof StartWorkflowExecutionRequest) {
352365 $ req ->setRequestEagerExecution ($ options ->eagerStart );
353366 }
0 commit comments