@@ -423,19 +423,19 @@ public String toString() {
423423 /** Represents an accepted update workflow execution request */
424424 static final class UpdateWorkflowExecutionData {
425425 final String id ;
426- final CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ;
427- final CompletableFuture <UpdateWorkflowExecutionResponse > complete ;
426+ final CompletableFuture <Boolean > accepted ;
427+ final CompletableFuture <Outcome > outcome ;
428428 final Request initialRequest ;
429429
430430 public UpdateWorkflowExecutionData (
431431 String id ,
432432 Request initialRequest ,
433- CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ,
434- CompletableFuture <UpdateWorkflowExecutionResponse > complete ) {
433+ CompletableFuture <Boolean > accepted ,
434+ CompletableFuture <Outcome > outcome ) {
435435 this .id = id ;
436436 this .initialRequest = initialRequest ;
437- this .acceptance = acceptance ;
438- this .complete = complete ;
437+ this .accepted = accepted ;
438+ this .outcome = outcome ;
439439 }
440440
441441 @ Override
@@ -560,10 +560,10 @@ public static StateMachine<ChildWorkflowData> newChildWorkflowStateMachine(
560560 public static StateMachine <UpdateWorkflowExecutionData > newUpdateWorkflowExecution (
561561 String updateId ,
562562 Request initialRequest ,
563- CompletableFuture <UpdateWorkflowExecutionResponse > acceptance ,
564- CompletableFuture <UpdateWorkflowExecutionResponse > complete ) {
563+ CompletableFuture <Boolean > accepted ,
564+ CompletableFuture <Outcome > outcome ) {
565565 return new StateMachine <>(
566- new UpdateWorkflowExecutionData (updateId , initialRequest , acceptance , complete ))
566+ new UpdateWorkflowExecutionData (updateId , initialRequest , accepted , outcome ))
567567 .add (NONE , START , STARTED , StateMachines ::acceptUpdate )
568568 .add (STARTED , COMPLETE , COMPLETED , StateMachines ::completeUpdate );
569569 }
@@ -1805,19 +1805,10 @@ private static void acceptUpdate(
18051805 if (!ctx .getWorkflowMutableState ().isTerminalState ()) {
18061806 ctx .addEvent (event );
18071807 }
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+ });
18211812 } catch (InvalidProtocolBufferException e ) {
18221813 throw new RuntimeException (e );
18231814 }
@@ -1849,20 +1840,10 @@ private static void completeUpdate(
18491840 if (!ctx .getWorkflowMutableState ().isTerminalState ()) {
18501841 ctx .addEvent (event );
18511842 }
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+ });
18661847 } catch (InvalidProtocolBufferException e ) {
18671848 throw new RuntimeException (e );
18681849 }
0 commit comments