@@ -21,6 +21,22 @@ export type WaitpointSystemOptions = {
2121 enqueueSystem : EnqueueSystem ;
2222} ;
2323
24+ type WaitpointContinuationWaitpoint = Pick < Waitpoint , "id" | "type" | "completedAfter" | "status" > ;
25+
26+ export type WaitpointContinuationResult =
27+ | {
28+ status : "unblocked" ;
29+ waitpoints : Array < WaitpointContinuationWaitpoint > ;
30+ }
31+ | {
32+ status : "skipped" ;
33+ reason : string ;
34+ }
35+ | {
36+ status : "blocked" ;
37+ waitpoints : Array < WaitpointContinuationWaitpoint > ;
38+ } ;
39+
2440export class WaitpointSystem {
2541 private readonly $ : SystemResources ;
2642 private readonly executionSnapshotSystem : ExecutionSnapshotSystem ;
@@ -480,7 +496,7 @@ export class WaitpointSystem {
480496 runId,
481497 } : {
482498 runId : string ;
483- } ) : Promise < "blocked" | "unblocked" | "skipped" > {
499+ } ) : Promise < WaitpointContinuationResult > {
484500 this . $ . logger . debug ( `continueRunIfUnblocked: start` , {
485501 runId,
486502 } ) ;
@@ -496,7 +512,7 @@ export class WaitpointSystem {
496512 batchId : true ,
497513 batchIndex : true ,
498514 waitpoint : {
499- select : { id : true , status : true } ,
515+ select : { id : true , status : true , type : true , completedAfter : true } ,
500516 } ,
501517 } ,
502518 } ) ;
@@ -507,7 +523,11 @@ export class WaitpointSystem {
507523 runId,
508524 blockingWaitpoints,
509525 } ) ;
510- return "blocked" ;
526+
527+ return {
528+ status : "blocked" ,
529+ waitpoints : blockingWaitpoints . map ( ( w ) => w . waitpoint ) ,
530+ } ;
511531 }
512532
513533 // 3. Get the run with environment
@@ -547,7 +567,10 @@ export class WaitpointSystem {
547567 executionStatus : snapshot . executionStatus ,
548568 } ) ;
549569
550- return "skipped" ;
570+ return {
571+ status : "skipped" ,
572+ reason : "run is already executing" ,
573+ } ;
551574 }
552575 case "QUEUED" : {
553576 this . $ . logger . info ( `continueRunIfUnblocked: run is queued, skipping` , {
@@ -556,7 +579,10 @@ export class WaitpointSystem {
556579 executionStatus : snapshot . executionStatus ,
557580 } ) ;
558581
559- return "skipped" ;
582+ return {
583+ status : "skipped" ,
584+ reason : "run is already queued" ,
585+ } ;
560586 }
561587 case "PENDING_EXECUTING" : {
562588 this . $ . logger . info ( `continueRunIfUnblocked: run is pending executing, skipping` , {
@@ -565,7 +591,10 @@ export class WaitpointSystem {
565591 executionStatus : snapshot . executionStatus ,
566592 } ) ;
567593
568- return "skipped" ;
594+ return {
595+ status : "skipped" ,
596+ reason : "run is already pending executing" ,
597+ } ;
569598 }
570599 case "QUEUED_EXECUTING" : {
571600 this . $ . logger . info ( `continueRunIfUnblocked: run is already queued executing, skipping` , {
@@ -574,7 +603,10 @@ export class WaitpointSystem {
574603 executionStatus : snapshot . executionStatus ,
575604 } ) ;
576605
577- return "skipped" ;
606+ return {
607+ status : "skipped" ,
608+ reason : "run is already queued executing" ,
609+ } ;
578610 }
579611 case "EXECUTING" : {
580612 this . $ . logger . info ( `continueRunIfUnblocked: run is already executing, skipping` , {
@@ -583,7 +615,10 @@ export class WaitpointSystem {
583615 executionStatus : snapshot . executionStatus ,
584616 } ) ;
585617
586- return "skipped" ;
618+ return {
619+ status : "skipped" ,
620+ reason : "run is already executing" ,
621+ } ;
587622 }
588623 case "PENDING_CANCEL" :
589624 case "FINISHED" : {
@@ -592,7 +627,10 @@ export class WaitpointSystem {
592627 snapshot,
593628 executionStatus : snapshot . executionStatus ,
594629 } ) ;
595- return "skipped" ;
630+ return {
631+ status : "skipped" ,
632+ reason : "run is finished" ,
633+ } ;
596634 }
597635 case "EXECUTING_WITH_WAITPOINTS" : {
598636 const newSnapshot = await this . executionSnapshotSystem . createExecutionSnapshot (
@@ -693,7 +731,10 @@ export class WaitpointSystem {
693731 } ) ;
694732 }
695733
696- return "unblocked" ;
734+ return {
735+ status : "unblocked" ,
736+ waitpoints : blockingWaitpoints . map ( ( w ) => w . waitpoint ) ,
737+ } ;
697738 } ) ; // end of runlock
698739 }
699740
0 commit comments