feat(http-client): add Android support and implement SPI for A2AHttpClient#806
Open
sherryfox wants to merge 1 commit intoa2aproject:0.3.x-compatfrom
Open
feat(http-client): add Android support and implement SPI for A2AHttpClient#806sherryfox wants to merge 1 commit intoa2aproject:0.3.x-compatfrom
sherryfox wants to merge 1 commit intoa2aproject:0.3.x-compatfrom
Conversation
4 tasks
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements a service-provider-based architecture for HTTP clients, enabling automatic resolution of the best implementation (e.g., Android vs. JDK) via an A2AHttpClientFactory. The changes include the addition of an AndroidA2AHttpClient and updates to various transport modules to utilize the new factory. Feedback focuses on enhancing the Android client's robustness by addressing potential data corruption in response parsing, implementing size limits to prevent memory issues, and using dedicated thread pools for network operations. Caching providers in the factory is also suggested to improve performance.
d56dddb to
f41989f
Compare
…lient - Introduce `AndroidA2AHttpClient` using `HttpURLConnection` for Android compatibility. - Implement `A2AHttpClientFactory` and `A2AHttpClientProvider` using `ServiceLoader` to decouple implementations. - Update `A2A` and transport providers to use the factory instead of hardcoding `JdkA2AHttpClient`. - Add `@JsonProperty` annotations to spec records to prevent parsing failures on Android.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR introduces Android support for the A2A HTTP client, decouples the hardcoded JDK client using the Service Provider Interface (SPI) pattern, and aligns with the upcoming Gson migration by rebasing onto the
0.3-workflowsbranch.🌟 Key Highlights
HttpURLConnection.JdkA2AHttpClientand introduced a factory to resolve the best client automatically.📦 Detailed Changes
1. HTTP Client Factory & SPI Pattern
Introduced a factory and provider interface to allow pluggable HTTP client implementations via
ServiceLoader.A2AHttpClientFactory.java: Created to load implementations ofA2AHttpClientProviderand select the one with the highest priority.A2AHttpClientProvider.java: Introduced as the interface for providers.http-client/src/main/resources/META-INF/services/io.a2a.client.http.A2AHttpClientProviderhttp-client/src/main/resources_android/META-INF/services/io.a2a.client.http.A2AHttpClientProvider2. Decoupling
JdkA2AHttpClientRemoved hardcoded dependencies on
JdkA2AHttpClientacross the codebase.JdkA2AHttpClientnow implementsA2AHttpClientProviderwith a default priority of0.A2AHttpClientFactory.create()instead of direct instantiation:A2A.java(inclient/base)A2ACardResolver.java(inhttp-client)JSONRPCTransportProvider.java(inclient/transport/jsonrpc)RestTransportProvider.java(inclient/transport/rest)3.
AndroidA2AHttpClientAndroidA2AHttpClient.javausingHttpURLConnection(which does not have forbidden dependencies on Android).A2AHttpClientProviderwith a priority of100, making it the preferred choice in Android environments.4. Alignment with Gson Migration
specrecords (likeAgentCapabilities,TaskStatus, etc.) as they are not needed in the Gson environment.5. Documentation & Fixes
README.mdto reflect that the default HTTP client is resolved automatically via the factory rather than being hardcoded.4.2.0(from the fork) inexamples/cloud-deployment/k8s/02-kafka.yamlto ensure compatibility with the CI environment.🧪 Verification Results
mvn clean install -DskipTests=true.http-clientmodule passed successfully (mvn test -pl http-client), including a new test verifying the factory behavior.Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #793 🦕