1313use Workflow \Serializers \CodecRegistry ;
1414use Workflow \Serializers \Serializer ;
1515use Workflow \V2 \CommandContext ;
16+ use Workflow \V2 \Contracts \HistoryProjectionRole ;
1617use Workflow \V2 \Enums \ActivityStatus ;
1718use Workflow \V2 \Enums \ChildCallStatus ;
1819use Workflow \V2 \Enums \CommandOutcome ;
@@ -1713,7 +1714,7 @@ private function scheduleChildWorkflow(
17131714 $ this ->markRunWaiting ($ run , $ task );
17141715 }
17151716
1716- RunSummaryProjector:: project (
1717+ $ this -> projectRun (
17171718 $ childRun ->fresh ([
17181719 'instance ' ,
17191720 'tasks ' ,
@@ -2240,7 +2241,7 @@ private function markRunWaiting(WorkflowRun $run, WorkflowTask $task): void
22402241 'lease_expires_at ' => null ,
22412242 ])->save ();
22422243
2243- RunSummaryProjector:: project (
2244+ $ this -> projectRun (
22442245 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
22452246 );
22462247 }
@@ -2496,7 +2497,7 @@ private function continueAsNew(
24962497
24972498 LifecycleEventDispatcher::workflowStarted ($ continuedRun );
24982499
2499- RunSummaryProjector:: project (
2500+ $ this -> projectRun (
25002501 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
25012502 );
25022503 foreach (array_keys ($ parentRunsToProject ) as $ parentRunId ) {
@@ -2507,7 +2508,7 @@ private function continueAsNew(
25072508 continue ;
25082509 }
25092510
2510- RunSummaryProjector:: project (
2511+ $ this -> projectRun (
25112512 $ parentRun ->fresh ([
25122513 'instance ' ,
25132514 'tasks ' ,
@@ -2521,7 +2522,7 @@ private function continueAsNew(
25212522 ])
25222523 );
25232524 }
2524- RunSummaryProjector:: project (
2525+ $ this -> projectRun (
25252526 $ continuedRun ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
25262527 );
25272528
@@ -2611,7 +2612,7 @@ private function completeRun(WorkflowRun $run, WorkflowTask $task, mixed $result
26112612
26122613 $ this ->dispatchParentResumeTasks ($ run );
26132614
2614- RunSummaryProjector:: project (
2615+ $ this -> projectRun (
26152616 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
26162617 );
26172618 }
@@ -2799,7 +2800,7 @@ private function timeoutRun(WorkflowRun $run, WorkflowTask $task): void
27992800 // Notify parent workflows and project summary.
28002801 $ this ->dispatchParentResumeTasks ($ run );
28012802
2802- RunSummaryProjector:: project (
2803+ $ this -> projectRun (
28032804 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
28042805 );
28052806 }
@@ -2899,7 +2900,7 @@ private function failRun(
28992900
29002901 $ this ->dispatchParentResumeTasks ($ run );
29012902
2902- RunSummaryProjector:: project (
2903+ $ this -> projectRun (
29032904 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
29042905 );
29052906 }
@@ -2978,7 +2979,7 @@ private function blockReplayUntilFailureCanBeRestored(
29782979 'lease_expires_at ' => null ,
29792980 ])->save ();
29802981
2981- RunSummaryProjector:: project (
2982+ $ this -> projectRun (
29822983 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
29832984 );
29842985 }
@@ -3008,7 +3009,7 @@ private function blockReplayUntilCompatibleConditionWaitDefinition(
30083009 'lease_expires_at ' => null ,
30093010 ])->save ();
30103011
3011- RunSummaryProjector:: project (
3012+ $ this -> projectRun (
30123013 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
30133014 );
30143015 }
@@ -3032,7 +3033,7 @@ private function blockReplayUntilCompatibleHistoryShape(
30323033 'lease_expires_at ' => null ,
30333034 ])->save ();
30343035
3035- RunSummaryProjector:: project (
3036+ $ this -> projectRun (
30363037 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
30373038 );
30383039 }
@@ -3365,7 +3366,7 @@ private function startChildRetryIfAvailable(
33653366
33663367 TaskDispatcher::dispatch ($ retryTask );
33673368
3368- RunSummaryProjector:: project (
3369+ $ this -> projectRun (
33693370 $ retryRun ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
33703371 );
33713372
@@ -3439,7 +3440,7 @@ private function dispatchParentResumeTasks(WorkflowRun $childRun): void
34393440 $ parentReference ['parent_sequence ' ],
34403441 $ childRun ,
34413442 ) !== null ) {
3442- RunSummaryProjector:: project (
3443+ $ this -> projectRun (
34433444 $ parentRun ->fresh ([
34443445 'instance ' ,
34453446 'tasks ' ,
@@ -3471,7 +3472,7 @@ private function dispatchParentResumeTasks(WorkflowRun $childRun): void
34713472 $ childStatus
34723473 )
34733474 ) {
3474- RunSummaryProjector:: project (
3475+ $ this -> projectRun (
34753476 $ parentRun ->fresh ([
34763477 'instance ' ,
34773478 'tasks ' ,
@@ -3496,7 +3497,7 @@ private function dispatchParentResumeTasks(WorkflowRun $childRun): void
34963497 $ parentReference ['parent_sequence ' ],
34973498 )
34983499 ) {
3499- RunSummaryProjector:: project (
3500+ $ this -> projectRun (
35003501 $ parentRun ->fresh ([
35013502 'instance ' ,
35023503 'tasks ' ,
@@ -3525,7 +3526,7 @@ private function dispatchParentResumeTasks(WorkflowRun $childRun): void
35253526 WorkflowStepHistory::CHILD_WORKFLOW ,
35263527 );
35273528 } catch (HistoryEventShapeMismatchException ) {
3528- RunSummaryProjector:: project (
3529+ $ this -> projectRun (
35293530 $ parentRun ->fresh ([
35303531 'instance ' ,
35313532 'tasks ' ,
@@ -3576,7 +3577,7 @@ private function dispatchParentResumeTasks(WorkflowRun $childRun): void
35763577
35773578 TaskDispatcher::dispatch ($ parentTask );
35783579
3579- RunSummaryProjector:: project (
3580+ $ this -> projectRun (
35803581 $ parentRun ->fresh ([
35813582 'instance ' ,
35823583 'tasks ' ,
@@ -4343,7 +4344,7 @@ private function restartAfterPendingUpdateFailure(WorkflowRun $run, WorkflowTask
43434344 'compatibility ' => $ run ->compatibility ,
43444345 ]);
43454346
4346- RunSummaryProjector:: project (
4347+ $ this -> projectRun (
43474348 $ run ->fresh (['instance ' , 'tasks ' , 'activityExecutions ' , 'timers ' , 'failures ' , 'historyEvents ' ])
43484349 );
43494350
@@ -4589,6 +4590,20 @@ private function visibleSequenceForAllCall(WorkflowRun $run, AllCall $current, i
45894590 return $ sequence ;
45904591 }
45914592
4593+ private function projectRun (WorkflowRun $ run ): void
4594+ {
4595+ $ this ->historyProjectionRole ()
4596+ ->projectRun ($ run );
4597+ }
4598+
4599+ private function historyProjectionRole (): HistoryProjectionRole
4600+ {
4601+ /** @var HistoryProjectionRole $role */
4602+ $ role = app (HistoryProjectionRole::class);
4603+
4604+ return $ role ;
4605+ }
4606+
45924607 private static function intValue (mixed $ value ): ?int
45934608 {
45944609 if (is_int ($ value )) {
0 commit comments