refactor(server): move REST routing into dedicated RestDispatcher#900
refactor(server): move REST routing into dedicated RestDispatcher#900guglielmo-san wants to merge 7 commits intoa2aproject:1.0-devfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the server's REST API handling by extracting the core execution logic from the routing layer into a dedicated Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/routes/rest_routes.py | 77.11% | 73.53% | 🔴 -3.58% |
| src/a2a/server/routes/rest_dispatcher.py (new) | — | 92.43% | — |
| Total | 91.47% | 91.56% | 🟢 +0.10% |
Generated by coverage-comment.yml
There was a problem hiding this comment.
Code Review
This pull request refactors the REST API handling by introducing a new RestDispatcher class, replacing the previous RESTHandler. The rest_routes.py file has been updated to utilize this new dispatcher for defining routes, centralizing the dispatch logic. A new test file, test_rest_dispatcher.py, has been added to cover the functionality of the RestDispatcher. Minor adjustments were also made to the validate_version decorator in src/a2a/utils/helpers.py. There is a bug where JSONRPCHandler is exported in src/a2a/server/request_handlers/__init__.py but not imported, which will cause a NameError. Additionally, it is recommended to add tests for successful streaming responses in test_rest_dispatcher.py to ensure robustness.
ebb394c to
d66afb1
Compare
|
|
||
|
|
||
| @trace_class(kind=SpanKind.SERVER) | ||
| class RestDispatcher: |
There was a problem hiding this comment.
| class RestDispatcher: | |
| class RESTDispatcher: |
Not sure if there's a general standard on this, but we should probably keep these acronyms as capitals, like we did for A2A, and how the previous RESTHandler class was setup
Description
This PR centralizes the execution logic for REST endpoints by extracting it from the routing layer (
rest_routes.py) into a dedicatedRestDispatcherclass. It simplifies the pipeline by directly binding the server endpoints to the core RequestHandler.Fixes #797 🦕