dapr / rust-sdk

Dapr SDK for Rust - Alpha
Apache License 2.0
209 stars 62 forks source link

Proc macros to reduce boiler plate #77

Open NickLarsenNZ opened 1 year ago

NickLarsenNZ commented 1 year ago

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?

NickLarsenNZ commented 1 year ago

Maybe it doesn't even need to consider HTTP handlers. It could just be a standalone event handler.

zedgell commented 1 year ago

@NickLarsenNZ I have added a PR for the Procedural Macro for the pub sub topic.

https://github.com/dapr/rust-sdk/pull/87

NickLarsenNZ commented 1 year ago

Nice one @zedgell

github-actions[bot] commented 2 months ago

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.

github-actions[bot] commented 1 month ago

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.