refactor: extract shared SSE event handling into SPI module#624
refactor: extract shared SSE event handling into SPI module#624kabir merged 1 commit intoa2aproject:mainfrom
Conversation
Summary of ChangesHello @ehsavoie, 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 improves the maintainability and consistency of Server-Sent Events (SSE) handling across different client transport mechanisms. By extracting common logic into a new Service Provider Interface (SPI) module, it centralizes event processing, error management, and connection auto-closure, reducing redundant code and simplifying future enhancements. Highlights
Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the Server-Sent Events (SSE) listener implementation by introducing an AbstractSSEEventListener in a new spi package. This abstract class centralizes common logic for event handling, error handling, and auto-closing SSE connections when final task events are received. The existing SSEEventListener in the jsonrpc transport and a newly created SSEEventListener in the rest transport (replacing the deleted RestSSEEventListener) now extend this abstract base class, delegating common responsibilities to it while retaining their transport-specific message parsing logic. Corresponding test files were added for the abstract class and updated/created for the concrete implementations to ensure the new structure and auto-close behavior function correctly. A minor change also added .bob/ to the .gitignore. A review comment suggested adding a @Nullable annotation to the errorHandler parameter in the rest package's SSEEventListener constructor for API consistency.
client/transport/rest/src/main/java/io/a2a/client/transport/rest/sse/SSEEventListener.java
Show resolved
Hide resolved
Create client-transport-spi module with AbstractSSEEventListener to eliminate code duplication between jsonrpc and rest transport implementations. - Add AbstractSSEEventListener with common event/error handling logic - Refactor jsonrpc and rest SSEEventListener to extend base class - Add comprehensive test coverage for shared functionality fix: issue a2aproject#623 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Create client-transport-spi module with AbstractSSEEventListener to eliminate code duplication between jsonrpc and rest transport implementations.
Fixes #623 🦕