Fill variables in redisson.yml with Spring Boot values.
See original GitHub issueIs your feature request related to a problem? Please describe.
We are using redisson-spring-boot-starter. We were hoping that we could configure Redisson with a redisson.yml, but also configure more dynamic properties from our application.yml.
# application.yml
spring:
redis:
host: ${REDIS_HOSTNAME}
redisson:
file: classpath:redisson.yaml
When we run in a different environment we can overwrite the Redis hostname by setting an environment variable. With Spring Boot profiles (for example “local”), we could have an application-local.yml that contains the following:
# application-local.yml
spring:
redis:
host: localhost
Or set the placeholder itself:
# application-local.yml
REDIS_HOSTNAME: localhost
That way we would be able to have different configurations for our local run configuration compared to what we use in our production systems. Detailed properties for Redisson (described in redisson.yml) are the same for all environment, while things like the host, port or ssl properties can change depending on the environment where the application is running.
Describe the solution you’d like
If the merging of application.yml(or application-local.yml) with redisson.yml is not possible, can we then maybe have some feature where we fill variables with Spring Boot values. That way the redisson.yml would be able to look like:
# redisson.yml
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
subscriptionsPerConnection: 5
address: "redis://${REDIS_HOSTNAME}:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 10
connectionPoolSize: 64
dnsMonitoringInterval: 5000
In such a way, we would be able to create an application-local.yml that looks like this:
# application-local.yml
REDIS_HOSTNAME: localhost
With Spring Boot values I mean the values described by externalized configuration here. That way there are many ways to inject variables into the configuration of Redisson.
Describe alternatives you’ve considered
We currently are using the following as an application.yml:
# application.yml
spring:
redis:
redisson:
config: |
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
subscriptionsPerConnection: 5
address: "redis://${ELASTICACHE_URL}:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 10
connectionPoolSize: 64
dnsMonitoringInterval: 5000
This works for us but puts a lot of detail for a specific dependency in the application.yml. These fields are never changed. The values are prone to mistakes.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:10 (6 by maintainers)
@Blockost
I’m ready to consider any contribution.
Any news on this @mrniko ? It’s been quite some time now since this feature request has been submitted but it does not seem to be implemented yet right ? I’m very interested in this !