Skip to content

Commit f5841e3

Browse files
update readme and example
1 parent 9c069b3 commit f5841e3

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

crates/sdk/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff 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)
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#![allow(unreachable_pub)]
22
use std::time::Duration;
3-
use temporalio_common::protos::coresdk::{
4-
AsJsonPayloadExt, workflow_commands::ContinueAsNewWorkflowExecution,
5-
};
63
use 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
}

0 commit comments

Comments
 (0)