Skip to content
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

Adding optional Rule to subscription annotations for PubSub routing #266

Merged
merged 8 commits into from
Aug 30, 2021

Conversation

pkedy
Copy link
Member

@pkedy pkedy commented Aug 30, 2021

Description

This PR allows the Python SDK to make use of the experimental PubSub feature in Dapr 1.4. This is done by using a new, optional rule parameter of the subscribe annotation.

Example:

# Specific handler using Pub/Sub routing
@app.subscribe(pubsub_name='pubsub', topic='TOPIC_A',
               rule=Rule("event.type == \"important\"", 1))
def mytopic_important(event: v1.Event) -> None:
    data = json.loads(event.Data())
    print(f'Received: id={data["id"]}, message="{data ["message"]}"' 
          ' content_type="{event.content_type}"',flush=True)

Note: gRPC/Protobufs were regenerated.

Issue reference

Part of dapr/dapr#2582

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

/cc @wcs1only

@codecov
Copy link

codecov bot commented Aug 30, 2021

Codecov Report

Merging #266 (35c83a9) into master (6007eb0) will increase coverage by 0.13%.
The diff coverage is 93.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
+ Coverage   88.71%   88.85%   +0.13%     
==========================================
  Files          52       52              
  Lines        2101     2144      +43     
==========================================
+ Hits         1864     1905      +41     
- Misses        237      239       +2     
Impacted Files Coverage Δ
dapr/clients/grpc/client.py 91.25% <80.00%> (-0.26%) ⬇️
ext/dapr-ext-grpc/tests/test_app.py 84.84% <87.50%> (-1.36%) ⬇️
ext/dapr-ext-grpc/dapr/ext/grpc/_servicier.py 95.68% <97.67%> (+1.64%) ⬆️
ext/dapr-ext-grpc/dapr/ext/grpc/__init__.py 100.00% <100.00%> (ø)
ext/dapr-ext-grpc/dapr/ext/grpc/app.py 83.33% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6007eb0...35c83a9. Read the comment docs.

@pkedy pkedy marked this pull request as ready for review August 30, 2021 21:28
@pkedy pkedy requested review from a team as code owners August 30, 2021 21:28
@wcs1only wcs1only merged commit 593817c into dapr:master Aug 30, 2021
@wcs1only wcs1only added this to the v1.3 milestone Aug 30, 2021
@pkedy pkedy deleted the pubsub_routing branch August 31, 2021 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants