Skip to content

Commit

Permalink
Revert greeter.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Sep 18, 2024
1 parent e0eb5fb commit cb77adc
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions examples/greeter.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
use restate_sdk::prelude::*;
use std::time::Duration;
use tracing::info;
use std::convert::Infallible;

#[restate_sdk::service]
trait Greeter {
async fn sleep() -> Result<(), HandlerError>;
async fn do_stuff() -> Result<String, HandlerError>;
async fn greet(name: String) -> Result<String, Infallible>;
}

struct GreeterImpl;

impl Greeter for GreeterImpl {
async fn sleep(&self, ctx: Context<'_>) -> Result<(), HandlerError> {
ctx.sleep(Duration::from_secs(120)).await?;
Ok(())
}

async fn do_stuff(&self, ctx: Context<'_>) -> Result<String, HandlerError> {
let call_handle = ctx.service_client::<GreeterClient>()
.sleep()
.call();

info!("Invocation id {}", call_handle.invocation_id().await?);

ctx.sleep(Duration::from_secs(5)).await?;

// Now cancel it
call_handle.cancel();

// Now await it
call_handle.await?;

Ok("This should have failed".to_string())
async fn greet(&self, _: Context<'_>, name: String) -> Result<String, Infallible> {
Ok(format!("Greetings {name}"))
}
}

Expand Down

0 comments on commit cb77adc

Please sign in to comment.