Open
Description
The Rust SDK currently forces you to write separate traits for all of your services, objects and workflows. I think it would be far more ergonomic to have the macro apply directly to the implementation body itself:
pub struct MyService;
#[restate_sdk::service]
impl MyService {
async fn my_handler(&self, _ctx: Context<'_>, greeting: String) -> Result<String, HandlerError> {
Ok(format!("{greeting}!"))
}
}
pub struct MyVirtualObject;
#[restate_sdk::object]
impl MyVirtualObject {
#[shared]
async fn my_concurrent_handler(
&self,
ctx: SharedObjectContext<'_>,
greeting: String,
) -> Result<String, HandlerError> {
Ok(format!("Greetings {} {}", greeting, ctx.key()))
}
}
pub struct MyWorkflow;
#[restate_sdk::workflow]
impl MyWorkflow {
async fn run(&self, _ctx: WorkflowContext<'_>, _req: String) -> Result<String, HandlerError> {
Ok(String::from("success"))
}
}
This also eliminates the awkward and non-idiomatic FooBar
<-> FooBarImpl
naming convention.
What do you think of this approach?