Description
Currently if sentinel properties are present in the default profile, no other spring profile can disable sentinel. Adding an explicit enabled property would allow backwards compatibility and also be consistent with multiple other spring projects. This would allow disabling sentinel in specific environments, such as during testing or in a non-HA environment.
Similar Examples
spring.data.jpa.repositories.enabled: Enables JPA repositories auto-configuration.
spring.data.mongodb.enabled: Enables MongoDB auto-configuration.
spring.data.redis.repositories.enabled: Enables Redis repositories auto-configuration.
spring.security.enabled: Enables Spring Security auto-configuration.
spring.sleuth.enabled: Enables Spring Cloud Sleuth for distributed tracing.
spring.batch.job.enabled: Enables Spring Batch job processing.
spring.jms.pub-sub-domain: Enables or disables the use of JMS pub-sub domain.
spring.jms.template.pub-sub-domain: Enables or disables the use of JMS pub-sub domain for the JmsTemplate.
spring.mail.enabled: Enables or disables the use of Spring Mail.
spring.webflux.enabled
Details
As written RedisSentinelConfiguration
and RedisProperties
look for existence of spring.redis.sentinel
to configure sentinel. Unfortunately spring does not support setting null values, so once these values exist they cannot be removed
Example
In my specific use case, someone has setup this in application.yml
spring:
redis:
sentinel:
master: ${REDIS_SENTINEL_MASTER_NAME}
nodes: ${REDIS_SENTINEL_NODES_ADDRESS}
We are already using embedded redis to support mocking, but adding the following code to out application-test.yml
does not stop sentinel from loading:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
sentinel:
master: null
nodes: null
Specific Project Versions
[INFO] +- org.springframework.boot:spring-boot-starter-data-redis:jar:2.7.9:compile
[INFO] | \- org.springframework.data:spring-data-redis:jar:2.7.8:compile
[INFO] | +- org.springframework.data:spring-data-keyvalue:jar:2.7.8:compile
[INFO] | +- org.springframework:spring-oxm:jar:5.3.25:compile
[INFO] | \- org.springframework:spring-context-support:jar:5.3.25:compile
[INFO] +- redis.clients:jedis:jar:3.8.0:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.36:compile