Skip to content

Commit cb77adc

Browse files
Revert greeter.rs
1 parent e0eb5fb commit cb77adc

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

examples/greeter.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
11
use restate_sdk::prelude::*;
2-
use std::time::Duration;
3-
use tracing::info;
2+
use std::convert::Infallible;
43

54
#[restate_sdk::service]
65
trait Greeter {
7-
async fn sleep() -> Result<(), HandlerError>;
8-
async fn do_stuff() -> Result<String, HandlerError>;
6+
async fn greet(name: String) -> Result<String, Infallible>;
97
}
108

119
struct GreeterImpl;
1210

1311
impl Greeter for GreeterImpl {
14-
async fn sleep(&self, ctx: Context<'_>) -> Result<(), HandlerError> {
15-
ctx.sleep(Duration::from_secs(120)).await?;
16-
Ok(())
17-
}
18-
19-
async fn do_stuff(&self, ctx: Context<'_>) -> Result<String, HandlerError> {
20-
let call_handle = ctx.service_client::<GreeterClient>()
21-
.sleep()
22-
.call();
23-
24-
info!("Invocation id {}", call_handle.invocation_id().await?);
25-
26-
ctx.sleep(Duration::from_secs(5)).await?;
27-
28-
// Now cancel it
29-
call_handle.cancel();
30-
31-
// Now await it
32-
call_handle.await?;
33-
34-
Ok("This should have failed".to_string())
12+
async fn greet(&self, _: Context<'_>, name: String) -> Result<String, Infallible> {
13+
Ok(format!("Greetings {name}"))
3514
}
3615
}
3716

0 commit comments

Comments
 (0)