Skip to content

Conversation

jamesforwardnwboxed
Copy link

@jamesforwardnwboxed jamesforwardnwboxed commented Jul 29, 2025

Right now this PR allows globally setting values in data-source-properties, via global.datasources.data-source-properties. We find this to be extremely helpful when enforcing organisational standards - for example, providing helm charts which provide these values out of the box which force connection pinning on PostgreSQL via assumeMinServerVersion and forcing the ApplicationName to match the provisioned microservice.

Naturally we could improve this in future to also allow global configuration of other properties rather than just the data-source-properties map, but this is a nice start

@CLAassistant
Copy link

CLAassistant commented Jul 29, 2025

CLA assistant check
All committers have signed the CLA.

@jamesforwardnwboxed
Copy link
Author

Hi @graemerocher , I was wondering if it would be possible to get this merged in at some point? not sure who else to ping to get a review

*
* @author James Forward
*/
@Requires(property = "global.datasources.data-source-properties")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better name would be global-data-source-properties

Copy link
Author

@jamesforwardnwboxed jamesforwardnwboxed Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dstepanov The idea was to have global at a higher level and then have the usual datasources properties underneath, which makes it extensible and more inline with the current setup, since these data source properties are already set at datasources.<datasourcename>.data-source-properties. For example, if we did want to set other properties that would usually be under datasources.<datasourcename>, such as a global username, it would be global.datasources.username

*/
@Requires(property = "global.datasources.data-source-properties")
@Singleton
public class GlobalDatasourceConfigModifier implements BeanCreatedEventListener<DatasourceConfiguration> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls make final, package private and annotate @Internal

*/
@Requires(property = "global.datasources.data-source-properties")
@ConfigurationProperties("global.datasources")
public class GlobalDatasourceProperties {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls make final and add javadoc to methods

@Requires(property = "global.datasources.data-source-properties")
@ConfigurationProperties("global.datasources")
public class GlobalDatasourceProperties {
private Map<String, String> dataSourceProperties = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this has to be mutatable?

}
}

Map<String, ?> getIndividualDsProperties() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this exposed?

Copy link
Author

@jamesforwardnwboxed jamesforwardnwboxed Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dstepanov The dbcp implementation needs to access the properties to work properly

@dstepanov
Copy link
Contributor

Instead of the listener you should inject the global conf and apply the settings in the post construct method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants