feat: Provide a more friendly builder-based way to configure transpor… · anFatum/a2a-java@5686c8e · GitHub
Skip to content

Commit 5686c8e

Browse files
authored
feat: Provide a more friendly builder-based way to configure transpor… (a2aproject#238)
…t configuration This PR is a proposal to make the transport configuration specific to a given transport implementation. This one will ease developer experience by providing a builder for configuring a Client in a more stricter way compare to what exists today. Also, this will help at getting rid of strong coupling with different transport implementations. Two benefits: Get rid of dependencies which may not be required (grpc dependencies if you only go for jsonrpc) Easier to provide new transport implementation (such as HTTP+JSON). # 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: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent aa75bf9 commit 5686c8e

44 files changed

Lines changed: 534 additions & 411 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 36 additions & 36 deletions

client/base/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@
2020
<dependencies>
2121
<dependency>
2222
<groupId>${project.groupId}</groupId>
23-
<artifactId>a2a-java-sdk-client-config</artifactId>
23+
<artifactId>a2a-java-sdk-http-client</artifactId>
2424
</dependency>
2525
<dependency>
2626
<groupId>${project.groupId}</groupId>
27-
<artifactId>a2a-java-sdk-http-client</artifactId>
27+
<artifactId>a2a-java-sdk-client-transport-spi</artifactId>
2828
</dependency>
2929
<dependency>
3030
<groupId>${project.groupId}</groupId>
31-
<artifactId>a2a-java-sdk-client-transport-spi</artifactId>
31+
<artifactId>a2a-java-sdk-client-transport-jsonrpc</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>${project.groupId}</groupId>
35+
<artifactId>a2a-java-sdk-client-transport-grpc</artifactId>
36+
<scope>test</scope>
3237
</dependency>
3338
<dependency>
3439
<groupId>${project.groupId}</groupId>

client/base/src/main/java/io/a2a/A2A.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Collections;
44
import java.util.Map;
55

6-
import io.a2a.client.A2ACardResolver;
6+
import io.a2a.client.http.A2ACardResolver;
77
import io.a2a.client.http.A2AHttpClient;
88
import io.a2a.client.http.JdkA2AHttpClient;
99
import io.a2a.spec.A2AClientError;

client/base/src/main/java/io/a2a/client/AbstractClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.function.BiConsumer;
88
import java.util.function.Consumer;
99

10-
import io.a2a.client.config.ClientCallContext;
10+
import io.a2a.client.transport.spi.interceptors.ClientCallContext;
1111
import io.a2a.spec.A2AClientException;
1212
import io.a2a.spec.AgentCard;
1313
import io.a2a.spec.DeleteTaskPushNotificationConfigParams;
@@ -387,4 +387,4 @@ public Consumer<Throwable> getStreamingErrorHandler() {
387387
return streamingErrorHandler;
388388
}
389389

390-
}
390+
}

client/base/src/main/java/io/a2a/client/Client.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import java.util.function.BiConsumer;
66
import java.util.function.Consumer;
77

8-
import io.a2a.client.config.ClientCallContext;
98
import io.a2a.client.config.ClientConfig;
9+
import io.a2a.client.transport.spi.interceptors.ClientCallContext;
1010
import io.a2a.client.transport.spi.ClientTransport;
1111
import io.a2a.spec.A2AClientError;
1212
import io.a2a.spec.A2AClientException;
@@ -28,20 +28,27 @@
2828
import io.a2a.spec.TaskQueryParams;
2929
import io.a2a.spec.TaskStatusUpdateEvent;
3030

31+
import static io.a2a.util.Assert.checkNotNullParam;
32+
3133
public class Client extends AbstractClient {
3234

3335
private final ClientConfig clientConfig;
3436
private final ClientTransport clientTransport;
3537
private AgentCard agentCard;
3638

37-
public Client(AgentCard agentCard, ClientConfig clientConfig, ClientTransport clientTransport,
39+
Client(AgentCard agentCard, ClientConfig clientConfig, ClientTransport clientTransport,
3840
List<BiConsumer<ClientEvent, AgentCard>> consumers, Consumer<Throwable> streamingErrorHandler) {
3941
super(consumers, streamingErrorHandler);
42+
checkNotNullParam("agentCard", agentCard);
43+
4044
this.agentCard = agentCard;
4145
this.clientConfig = clientConfig;
4246
this.clientTransport = clientTransport;
4347
}
4448

49+
public static ClientBuilder builder(AgentCard agentCard) {
50+
return new ClientBuilder(agentCard);
51+
}
4552

4653
@Override
4754
public void sendMessage(Message request, ClientCallContext context) throws A2AClientException {
Lines changed: 164 additions & 0 deletions

0 commit comments

Comments
 (0)