[automatic failover] Add Dynamic Weight Management for Redis Multi-Database Connections#3672
[automatic failover] Add Dynamic Weight Management for Redis Multi-Database Connections#3672atakavci wants to merge 4 commits intoredis:mainfrom
Conversation
- add setWeight - add tests - format
There was a problem hiding this comment.
Pull request overview
Adds runtime weight updates for multi-database Redis failover connections so endpoint priority can be adjusted without recreating connections.
Changes:
- Extends
RedisDatabasewith a runtimesetWeight(float)API and makesRedisDatabaseImpl.weightmutable. - Updates terminology in Javadocs from “load balancing” to “endpoint priority”.
- Adds unit/integration tests covering weight retrieval and updates.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/io/lettuce/core/failover/api/RedisDatabase.java |
Adds setWeight(float) to the public database API. |
src/main/java/io/lettuce/core/failover/RedisDatabaseImpl.java |
Makes weight mutable and implements setWeight. |
src/main/java/io/lettuce/core/failover/api/DatabaseConfig.java |
Updates Javadocs to reflect endpoint-priority semantics. |
src/main/java/io/lettuce/core/failover/api/BaseRedisMultiDbConnection.java |
Updates addDatabase parameter documentation for endpoint priority. |
src/test/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImplUnitTests.java |
Adds unit tests for weight get/set and edge values. |
src/test/java/io/lettuce/core/failover/StatefulMultiDbConnectionIntegrationTests.java |
Adds integration tests for weight operations via connection APIs. |
src/test/java/io/lettuce/core/failover/DatabaseConfigBuilderUnitTests.java |
Updates example naming/terminology around weights. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImplUnitTests.java
Outdated
Show resolved
Hide resolved
ggivo
left a comment
There was a problem hiding this comment.
When adding or removing databases, we evaluate and switch to the database with the highest weight.
However, changing the weights does not currently trigger a re-evaluation or switch. I would expect weight updates to behave similarly to add/remove operations and trigger a switch to the highest-weighted database.
ggivo
left a comment
There was a problem hiding this comment.
When adding or removing databases, we evaluate and switch to the database with the highest weight.
However, changing the weights does not currently trigger a re-evaluation or switch. I would expect weight updates to behave similarly to add/remove operations and trigger a switch to the highest-weighted database.
src/test/java/io/lettuce/core/failover/StatefulMultiDbConnectionIntegrationTests.java
Show resolved
Hide resolved
@ggivo adding/removing db does not trigger a failback/failover directly. Right now fundamental parts are there to set/switch/failover in case user likes to do so. |
- adding unit test for setting a higher weight dynamically causes a failback
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@atakavci |
Summary
Adds the ability to dynamically update database weights at runtime for multi-database Redis connections, enabling flexible endpoint priority adjustments without reconnection.
Changes
API Enhancements
setWeight(float)method toRedisDatabaseinterfaceweightfield mutable inRedisDatabaseImplDocumentation Updates
DatabaseConfig,BaseRedisMultiDbConnection, andRedisDatabaseTest Coverage
Use Case
Allows runtime adjustment of database priorities for failover scenarios without requiring connection recreation.