-
Notifications
You must be signed in to change notification settings - Fork 123
feat!: Remove hard dependency on MicroProfile Config from the core SDK #469
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
6 changes: 6 additions & 0 deletions
6
extras/task-store-database-jpa/src/main/resources/META-INF/a2a-defaults.properties
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # A2A JPA Database Task Store Default Configuration | ||
|
|
||
| # Grace period for task finalization in replicated scenarios (seconds) | ||
| # After a task reaches a final state, this is the minimum time to wait before cleanup | ||
| # to allow replicated events to arrive and be processed | ||
| a2a.replication.grace-period-seconds=15 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # A2A Java SDK - MicroProfile Config Integration | ||
|
|
||
| This optional integration module provides MicroProfile Config support for the A2A Java SDK configuration system. | ||
|
|
||
| ## Overview | ||
|
|
||
| The A2A Java SDK core uses the `A2AConfigProvider` interface for configuration, with default values loaded from `META-INF/a2a-defaults.properties` files on the classpath. | ||
|
|
||
| This module provides `MicroProfileConfigProvider`, which integrates with MicroProfile Config to allow configuration via: | ||
| - `application.properties` | ||
| - Environment variables | ||
| - System properties (`-D` flags) | ||
| - Custom ConfigSources | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Add Dependency | ||
|
|
||
| ```xml | ||
| <dependency> | ||
| <groupId>io.github.a2asdk</groupId> | ||
| <artifactId>a2a-java-sdk-microprofile-config</artifactId> | ||
| <version>${io.a2a.sdk.version}</version> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| ### 2. Configure Properties | ||
|
|
||
| Once the dependency is added, you can override any A2A configuration property: | ||
|
|
||
| **application.properties:** | ||
| ```properties | ||
| # Executor configuration | ||
| a2a.executor.core-pool-size=10 | ||
| a2a.executor.max-pool-size=100 | ||
|
|
||
| # Timeout configuration | ||
| a2a.blocking.agent.timeout.seconds=60 | ||
| a2a.blocking.consumption.timeout.seconds=10 | ||
| ``` | ||
|
|
||
| **Environment variables:** | ||
| ```bash | ||
| export A2A_EXECUTOR_CORE_POOL_SIZE=10 | ||
| export A2A_BLOCKING_AGENT_TIMEOUT_SECONDS=60 | ||
| ``` | ||
|
|
||
| **System properties:** | ||
| ```bash | ||
| java -Da2a.executor.core-pool-size=10 -jar your-app.jar | ||
| ``` | ||
|
|
||
| ## How It Works | ||
|
|
||
| The `MicroProfileConfigProvider` implementation: | ||
|
|
||
| 1. **First tries MicroProfile Config** - Checks `application.properties`, environment variables, system properties, and custom ConfigSources | ||
| 2. **Falls back to defaults** - If not found, uses values from `META-INF/a2a-defaults.properties` provided by core modules and extras | ||
| 3. **Priority 50** - Can be overridden by custom providers with higher priority | ||
|
|
||
| ## Configuration Fallback Chain | ||
|
|
||
| ``` | ||
| MicroProfile Config Sources (application.properties, env vars, -D flags) | ||
| ↓ (not found?) | ||
| DefaultValuesConfigProvider | ||
| → Scans classpath for ALL META-INF/a2a-defaults.properties files | ||
| → Merges all discovered properties together | ||
| → Throws exception if duplicate keys found | ||
| ↓ (property exists?) | ||
| Return merged default value | ||
| ↓ (not found?) | ||
| IllegalArgumentException | ||
| ``` | ||
|
|
||
| **Note**: All `META-INF/a2a-defaults.properties` files (from server-common, extras modules, etc.) are loaded and merged together by `DefaultValuesConfigProvider` at startup. This is not a sequential fallback chain, but a single merged set of defaults. | ||
|
|
||
| ## Available Configuration Properties | ||
|
|
||
| See the [main README](../../README.md#configuration-system) for a complete list of configuration properties. | ||
|
|
||
| ## Framework Compatibility | ||
|
|
||
| This module works with any MicroProfile Config implementation: | ||
|
|
||
| - **Quarkus** - Built-in MicroProfile Config support | ||
| - **Helidon** - Built-in MicroProfile Config support | ||
| - **Open Liberty** - Built-in MicroProfile Config support | ||
| - **WildFly/JBoss EAP** - Add `smallrye-config` dependency | ||
| - **Other Jakarta EE servers** - Add MicroProfile Config implementation | ||
|
|
||
| ## Custom Config Providers | ||
|
|
||
| If you're using a different framework (Spring, Micronaut, etc.), you can implement your own `A2AConfigProvider`: | ||
|
|
||
| ```java | ||
| import io.a2a.server.config.A2AConfigProvider; | ||
| import io.a2a.server.config.DefaultValuesConfigProvider; | ||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.enterprise.inject.Alternative; | ||
| import jakarta.annotation.Priority; | ||
| import jakarta.inject.Inject; | ||
|
|
||
| @ApplicationScoped | ||
| @Alternative | ||
| @Priority(100) // Higher than MicroProfileConfigProvider's priority of 50 | ||
| public class OtherEnvironmentConfigProvider implements A2AConfigProvider { | ||
|
|
||
| @Inject | ||
| Environment env; | ||
|
|
||
| @Inject | ||
| DefaultValuesConfigProvider defaultValues; | ||
|
|
||
| @Override | ||
| public String getValue(String name) { | ||
| String value = env.getProperty(name); | ||
| if (value != null) { | ||
| return value; | ||
| } | ||
| // Fallback to defaults | ||
| return defaultValues.getValue(name); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<String> getOptionalValue(String name) { | ||
| String value = env.getProperty(name); | ||
| if (value != null) { | ||
| return Optional.of(value); | ||
| } | ||
| return defaultValues.getOptionalValue(name); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| - **Package**: `io.a2a.integrations.microprofile` | ||
| - **Class**: `MicroProfileConfigProvider` | ||
| - **Priority**: 50 (can be overridden) | ||
| - **Scope**: `@ApplicationScoped` | ||
| - **Dependencies**: MicroProfile Config API, A2A SDK server-common | ||
|
|
||
| ## Reference Implementations | ||
|
|
||
| The A2A Java SDK reference implementations (Quarkus-based) automatically include this integration module, so MicroProfile Config properties work out of the box. | ||
|
|
||
| If you're building a custom server implementation, add this dependency to enable property-based configuration. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?xml version="1.0"?> | ||
| <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
| xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>io.github.a2asdk</groupId> | ||
| <artifactId>a2a-java-sdk-parent</artifactId> | ||
| <version>0.3.3.Beta1-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
| <artifactId>a2a-java-sdk-microprofile-config</artifactId> | ||
|
|
||
| <packaging>jar</packaging> | ||
|
|
||
| <name>A2A Java SDK - MicroProfile Config Integration</name> | ||
| <description>MicroProfile Config integration for A2A Java SDK - provides A2AConfigProvider implementation</description> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>a2a-java-sdk-server-common</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>jakarta.enterprise</groupId> | ||
| <artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>jakarta.inject</groupId> | ||
| <artifactId>jakarta.inject-api</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.eclipse.microprofile.config</groupId> | ||
| <artifactId>microprofile-config-api</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- Test dependencies --> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-arc</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-junit5</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and avoid magic strings, it's best to declare the configuration key as a
private static final Stringconstant. This prevents typos and makes it easier to manage keys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix upstream. It was already reviewed and merged there