File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,12 +237,8 @@ let result = started.result().await?;
237237### Continue-As-New
238238
239239``` rust
240- // To continue as new, return an error with WorkflowTermination::ContinueAsNew
241- Err (WorkflowTermination :: continue_as_new (ContinueAsNewWorkflowExecution {
242- workflow_type : " MyWorkflow" . to_string (),
243- arguments : vec! [new_input . into ()],
244- .. Default :: default ()
245- }))
240+ // To continue as new, use the workflow context helper and propagate the termination
241+ ctx . continue_as_new (& new_input , ContinueAsNewOptions :: default ())? ;
246242```
247243
248244### Patching (Versioning)
Original file line number Diff line number Diff line change 11#![ allow( unreachable_pub) ]
22use std:: time:: Duration ;
3- use temporalio_common:: protos:: coresdk:: {
4- AsJsonPayloadExt , workflow_commands:: ContinueAsNewWorkflowExecution ,
5- } ;
63use temporalio_macros:: { workflow, workflow_methods} ;
7- use temporalio_sdk:: { WorkflowContext , WorkflowResult , WorkflowTermination } ;
4+ use temporalio_sdk:: { ContinueAsNewOptions , WorkflowContext , WorkflowResult } ;
85
96#[ workflow]
107#[ derive( Default ) ]
@@ -18,18 +15,12 @@ impl ContinueAsNewWorkflow {
1815 ctx. timer ( Duration :: from_millis ( 100 ) ) . await ;
1916
2017 if current_iteration < max_iterations {
21- Err ( WorkflowTermination :: continue_as_new (
22- ContinueAsNewWorkflowExecution {
23- arguments : vec ! [
24- ( current_iteration + 1 , max_iterations)
25- . as_json_payload( )
26- . unwrap( ) ,
27- ] ,
28- ..Default :: default ( )
29- } ,
30- ) )
31- } else {
32- Ok ( format ! ( "Completed after {max_iterations} iterations" ) )
18+ ctx. continue_as_new (
19+ & ( current_iteration + 1 , max_iterations) ,
20+ ContinueAsNewOptions :: default ( ) ,
21+ ) ?;
3322 }
23+
24+ Ok ( format ! ( "Completed after {max_iterations} iterations" ) )
3425 }
3526}
You can’t perform that action at this time.
0 commit comments