rust-sdk
rust-sdk copied to clipboard
Proc macros to reduce boiler plate
Dapr seems quite easy to get going in other languages that provide annotations/attributes. I think the same should be done for the Rust SDK.
For example:
[Topic("pubsub", "orders")]
[HttpPost("/checkout")]
public async Task<ActionResult<Order>>Checkout(Order order, [FromServices] DaprClient daprClient)
{
// Logic
return order;
}
Could be expressed as:
#[topic(pub_sub_name = "pubsub", topic = "orders")]
#[post("/checkout")]
async fn hello(order: Order) -> String {
format!("Order id: {}", order.id)
}
Am I right in thinking that the difficulty comes in the variety of HTTP server crates? Or is that quite decoupled from decorating the handler?
Maybe it doesn't even need to consider HTTP handlers. It could just be a standalone event handler.
@NickLarsenNZ I have added a PR for the Procedural Macro for the pub sub topic.
https://github.com/dapr/rust-sdk/pull/87
Nice one @zedgell
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue or help wanted. Thank you for your contributions.