-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor Macros to Apply to Impl Blocks for Ergonomics (#43) #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Modify the procedural macros in ast.rs, gen.rs, and lib.rs to apply directly to impl blocks instead of traits, per Issue restatedev#43. This eliminates the need for separate trait definitions and simplifies the SDK's usage. New macro syntax examples: - #[restate_sdk::service] or #[restate_sdk::service(vis = "pub", name = "my_service")] - #[restate_sdk::object] or #[restate_sdk::object(vis = "pub")] - #[restate_sdk::workflow(name = "my_workflow")] - Method attributes: #[handler], #[handler(shared)], or #[handler(name = "my_handler")]
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the changes to the macro won't support both the impl block and the trait? Because I think we should support both impl block and trait.
The trait variant is perfect when you need to strongly separate in different modules of your project the "API" of the service (containing, among the others, the macro generated client) and the "IMPL" of the service (which perhaps you want it to live in a separate module).
Hello, @slinkydeveloper, I think I misunderstood the intent of this issue and removed trait support—will add it back. Questions:
Let me know. |
Any progress here? The new macro looks so much more ergonomic. |
Hi @musjj, Haven't progressed since due to questions on new/old syntax. Like the |
Hi, sorry but TBH I won't have much time for this PR any time soon, we've other priorities atm and before this PR I would like to complete #33 first. |
This PR addresses Issue #43 by refactoring the
restate-sdk-rust
macros to apply directly toimpl
blocks instead of requiring separate trait definitions. The change improves ergonomics, eliminates the need forFooBar
/FooBarImpl
naming conventions, and aligns the SDK with more idiomatic Rust patterns.Current Macros:
#[service]
,#[object]
, and#[workflow]
with support for optional attributes likevis = "pub"
which is needed to control the visibility of the generatedServe
andClient
structs andname = "my_service"
for overriding the service name.#[handler]
to mark which of the methods are service handlers. It also supports optional attributes likename = "my_handler"
to override the handler name andshared
in case of having anObject
or aWorkflow
to support concurrent use of the handler.Example: