@@ -423,19 +423,19 @@ public String toString() {
423
423
/** Represents an accepted update workflow execution request */
424
424
static final class UpdateWorkflowExecutionData {
425
425
final String id ;
426
- final CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ;
427
- final CompletableFuture <UpdateWorkflowExecutionResponse > complete ;
426
+ final CompletableFuture <Boolean > accepted ;
427
+ final CompletableFuture <Outcome > outcome ;
428
428
final Request initialRequest ;
429
429
430
430
public UpdateWorkflowExecutionData (
431
431
String id ,
432
432
Request initialRequest ,
433
- CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ,
434
- CompletableFuture <UpdateWorkflowExecutionResponse > complete ) {
433
+ CompletableFuture <Boolean > accepted ,
434
+ CompletableFuture <Outcome > outcome ) {
435
435
this .id = id ;
436
436
this .initialRequest = initialRequest ;
437
- this .acceptance = acceptance ;
438
- this .complete = complete ;
437
+ this .accepted = accepted ;
438
+ this .outcome = outcome ;
439
439
}
440
440
441
441
@ Override
@@ -560,10 +560,10 @@ public static StateMachine<ChildWorkflowData> newChildWorkflowStateMachine(
560
560
public static StateMachine <UpdateWorkflowExecutionData > newUpdateWorkflowExecution (
561
561
String updateId ,
562
562
Request initialRequest ,
563
- CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ,
564
- CompletableFuture <UpdateWorkflowExecutionResponse > complete ) {
563
+ CompletableFuture <Boolean > accepted ,
564
+ CompletableFuture <Outcome > outcome ) {
565
565
return new StateMachine <>(
566
- new UpdateWorkflowExecutionData (updateId , initialRequest , acceptance , complete ))
566
+ new UpdateWorkflowExecutionData (updateId , initialRequest , accepted , outcome ))
567
567
.add (NONE , START , STARTED , StateMachines ::acceptUpdate )
568
568
.add (STARTED , COMPLETE , COMPLETED , StateMachines ::completeUpdate );
569
569
}
@@ -1805,19 +1805,10 @@ private static void acceptUpdate(
1805
1805
if (!ctx .getWorkflowMutableState ().isTerminalState ()) {
1806
1806
ctx .addEvent (event );
1807
1807
}
1808
-
1809
- UpdateWorkflowExecutionResponse response =
1810
- UpdateWorkflowExecutionResponse .newBuilder ()
1811
- .setUpdateRef (
1812
- UpdateRef .newBuilder ()
1813
- .setWorkflowExecution (ctx .getExecution ())
1814
- .setUpdateId (data .id ))
1815
- .setStage (
1816
- UpdateWorkflowExecutionLifecycleStage
1817
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED )
1818
- .build ();
1819
-
1820
- data .acceptance .complete (response );
1808
+ ctx .onCommit (
1809
+ (int historySize ) -> {
1810
+ data .accepted .complete (true );
1811
+ });
1821
1812
} catch (InvalidProtocolBufferException e ) {
1822
1813
throw new RuntimeException (e );
1823
1814
}
@@ -1849,20 +1840,10 @@ private static void completeUpdate(
1849
1840
if (!ctx .getWorkflowMutableState ().isTerminalState ()) {
1850
1841
ctx .addEvent (event );
1851
1842
}
1852
-
1853
- UpdateWorkflowExecutionResponse updateResponse =
1854
- UpdateWorkflowExecutionResponse .newBuilder ()
1855
- .setUpdateRef (
1856
- UpdateRef .newBuilder ()
1857
- .setWorkflowExecution (ctx .getExecution ())
1858
- .setUpdateId (data .id ))
1859
- .setOutcome (response .getOutcome ())
1860
- .setStage (
1861
- UpdateWorkflowExecutionLifecycleStage
1862
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED )
1863
- .build ();
1864
-
1865
- data .complete .complete (updateResponse );
1843
+ ctx .onCommit (
1844
+ (int historySize ) -> {
1845
+ data .outcome .complete (response .getOutcome ());
1846
+ });
1866
1847
} catch (InvalidProtocolBufferException e ) {
1867
1848
throw new RuntimeException (e );
1868
1849
}
0 commit comments