adutra commented on PR #1482:
URL: https://github.com/apache/polaris/pull/1482#issuecomment-2844756603
> IIUC you mean removing default-datasource ? i think we need default being
explicit called out from the configuration. I am not entirely sure what do you
imply by `SmallRye's convention` ? can you please elaborate
@singhpk234 in SmallRye when you are mapping a `Map` you have the
possibility to define a special key called the "unnamed" key. That key in the
map will hold the default value for the map. You generally don't need to define
an extra property to hold the default value, the default value will be read
from the "root":
```java
@ConfigMapping(prefix = "polaris.relation.jdbc.datasource")
public interface RelationalJdbcConfiguration {
String DEFAULT_REALM_KEY = "<default>";
/** realmId to configured Datasource name mapping. */
@WithParentName
@WithUnnamedKey(DEFAULT_REALM_KEY)
Map<String, String> realms();
}
```
An example configuration would be:
```properties
# Default config:
polaris.relation.jdbc.datasource=realm1_ds
# Alternative configs per realm:
polaris.relation.jdbc.datasource.realm2=realm2_ds
polaris.relation.jdbc.datasource.realm3=realm3_ds
```
A typical usage would be:
```java
String dataSourceName;
if (relationalJdbcConfiguration.realms().containsKey(realmId)) {
dataSourceName = relationalJdbcConfiguration.realms().get(realmId);
} else {
dataSourceName =
relationalJdbcConfiguration.realms().get(RelationalJdbcConfiguration.DEFAULT_REALM_KEY);
}
```
This convention is used in many other places, so from a user XP perspective
it would be nice to have the same here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]