dapr / python-sdk

Dapr SDK for Python
Apache License 2.0
230 stars 128 forks source link

[feat]: Implement priority in the Rule class #568

Closed danielbichuetti closed 1 year ago

danielbichuetti commented 1 year ago

It would be nice if the Python SDK implements the priority parameter in the Rule class. It's used by the pub/sub routing mechanism.

Currently, .NET and GO SDKs implement it.

@app.subscribe(
    pubsub_name=PUBSUB_NAME,
    topic=TOPIC_NAME,
    rule=Rule(match='has(event.data.important) && event.data.important== true', priority=1),
)
berndverst commented 1 year ago

We already have this in Python for 2 years. https://github.com/dapr/python-sdk/pull/266

https://github.com/dapr/python-sdk/blob/7f181f312515946f12aa75d3e36a7fd2d3a51550/ext/dapr-ext-grpc/dapr/ext/grpc/_servicier.py#L39-L42

You should be able to use exactly what you suggested. I'll close this issue because it is already implemented. Feel free to leave a comment however and I'll see the comment.

And of course we'd welcome PRs to update our samples or docs.