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

Feature/topic route #200

Merged
merged 9 commits into from
Oct 26, 2021
Merged

Conversation

ran-ka
Copy link
Contributor

@ran-ka ran-ka commented Oct 16, 2021

Description

This pull request adds support for a topic_route decorator which behaves exactly like table_route but for a topic. i.e. it routes the web request to the worker that processes the partition of a given topic and key.

This is especially useful for monitoring live topic data or intermediate results for stateless workers that don't store data in a table.

Implementation

I didn't want to change any of the existing interfaces so in some areas I just duplicated the table_route code.
The additional information of the topic partition distribution is stored in the user_data as external_topic_distribution.

Testing

To test this feature I slightly modified the word_count.py example
Run two workers:
faust -A word_count.app --datadir=word-counts-data/worker0 worker --web-port 8000 --web-host localhost -l info
faust -A word_count.app --datadir=word-counts-data/worker1 worker --web-port 8001 --web-host localhost -l info

And test the last value:
curl localhost:8000/last/fox/
curl localhost:8001/last/fox/

Expect the same result from both workers
{"fox": {"the": 0, "quick": 0, "brown": 18222, "fox": 16000}}

Repeat this for other words: the quick, brown... and see the last values for each worker

Please let me know if you have any questions on the implementation or ideas on how to improve this...

raise TypeError("Need one of query_param, shard_param, or exact key")

@wraps(fun)
async def get(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support only get so no other HTTP operations will be supported here. Could you add that note as a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @patkivikram!

Have you seen this?
#191

I believe it adds a support for other methods... I can add another unit test to verify this... Makes sense?

Copy link
Contributor

@taybin taybin Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we were only supporting get before? Should #191 be reversed? @patkivikram

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't think it's a problem, but I am not sure what's the use case for other methods... I mean I get why we are using GET for table_route, to get table values from other workers when the state is distributed, but I don't see how POST is useful, because you can't really modify table values outside of stream operations... And if you send something to a stream, well, then you can send it from any worker, the send doesn't have to come from a specific worker. But maybe there is another use case that I am not aware of.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct we don't need PUT/POST/DELETE which is why I asked you to document

@codecov-commenter
Copy link

Codecov Report

Merging #200 (902750c) into master (7600f45) will increase coverage by 0.00%.
The diff coverage is 95.74%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #200   +/-   ##
=======================================
  Coverage   94.46%   94.46%           
=======================================
  Files         100      100           
  Lines       10643    10684   +41     
  Branches     1199     1204    +5     
=======================================
+ Hits        10054    10093   +39     
- Misses        524      526    +2     
  Partials       65       65           
Impacted Files Coverage Δ
faust/app/router.py 96.92% <91.30%> (-3.08%) ⬇️
faust/app/base.py 99.51% <100.00%> (+0.01%) ⬆️

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 7600f45...902750c. Read the comment docs.

@patkivikram patkivikram merged commit 4c1efbd into faust-streaming:master Oct 26, 2021
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.

4 participants