File tree Expand file tree Collapse file tree 1 file changed +4
-25
lines changed Expand file tree Collapse file tree 1 file changed +4
-25
lines changed Original file line number Diff line number Diff line change 1
1
use restate_sdk:: prelude:: * ;
2
- use std:: time:: Duration ;
3
- use tracing:: info;
2
+ use std:: convert:: Infallible ;
4
3
5
4
#[ restate_sdk:: service]
6
5
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 > ;
9
7
}
10
8
11
9
struct GreeterImpl ;
12
10
13
11
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}" ) )
35
14
}
36
15
}
37
16
You can’t perform that action at this time.
0 commit comments