feat(session): a unified Redis session client that supports switching between underlying clients#611
feat(session): a unified Redis session client that supports switching between underlying clients#611benym wants to merge 21 commits intoagentscope-ai:mainfrom
Conversation
# Conflicts: # agentscope-dependencies-bom/pom.xml
|
|
Summary of ChangesHello @benym, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Redis session management within AgentScope by introducing a unified RedisSession client. This new implementation leverages an adapter pattern to abstract away the underlying Redis client library, enabling seamless integration with Jedis, Lettuce, and Redisson, and supporting diverse Redis deployment topologies like standalone, cluster, and sentinel. This change streamlines the session management API, reduces code duplication, and improves flexibility for users operating in various production environments. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
ptal,thx @AlbumenJ @chickenlj |
There was a problem hiding this comment.
Code Review
This pull request introduces a unified RedisSession client, which is a significant improvement for supporting various Redis clients (Jedis, Lettuce, Redisson) and deployment modes. The use of the adapter pattern is well-executed. I've identified a few areas for improvement, primarily concerning performance and documentation accuracy. The Jedis and Lettuce adapters currently use the KEYS command, which can pose a performance risk in production; I've suggested switching to SCAN. Additionally, there are some inaccuracies in Javadoc and README examples that should be corrected for clarity. Overall, this is a great feature addition.
...s-session-redis/src/main/java/io/agentscope/core/session/redis/jedis/JedisClientAdapter.java
Show resolved
Hide resolved
...ssion-redis/src/main/java/io/agentscope/core/session/redis/lettuce/LettuceClientAdapter.java
Show resolved
Hide resolved
agentscope-extensions/agentscope-extensions-session-redis/README.md
Outdated
Show resolved
Hide resolved
agentscope-extensions/agentscope-extensions-session-redis/README_zh.md
Outdated
Show resolved
Hide resolved
...pe-extensions-session-redis/src/main/java/io/agentscope/core/session/redis/RedisSession.java
Show resolved
Hide resolved
...ion-redis/src/main/java/io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
...ensions-session-redis/src/main/java/io/agentscope/core/session/redis/RedisClientAdapter.java
Outdated
Show resolved
Hide resolved
...ion-redis/src/main/java/io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java
Outdated
Show resolved
Hide resolved
...ssion-redis/src/main/java/io/agentscope/core/session/redis/lettuce/LettuceClientAdapter.java
Outdated
Show resolved
Hide resolved
|
done. please check again. @AlbumenJ |
| * </ul> | ||
| */ | ||
| @Deprecated | ||
| public class JedisSession implements Session { |
There was a problem hiding this comment.
Can we reuse this class?
There was a problem hiding this comment.
Can we reuse this class?
This class is unlikely to be reused. JedisPool in JedisSession can be replaced with UnifiedJedis to adapt to various Redis deployment environments, but I don't think it's necessary to maintain this class anymore. This would allow for multiple parallel implementations of Redis-based sessions, and the core logic of session-based systems is clearly repetitive. The core logic of RedisSeesion is based on JedisSeesion, using an adapter design to hide the underlying client operations. I believe that for users, Jedis is just a client; they are actually operating Redis. Therefore, a unified RedisSeesion is sufficient. If Jedis is needed, the switch can be completed by specifying the Jedis client during initialization. Now that everything can be unified under a single RedisSession, the old implementation can be deprecated, reducing maintenance burden.
There was a problem hiding this comment.
From a design perspective, the adapter handles the client commands for operating Redis, while existing JedisSession and RedissonSession handle session operation logic. This part is largely reusable and doesn't need to be implemented repeatedly for the client.
AgentScope-Java Version
1.0.8-SNAPSHOT
Description
releted to #610
Background
The current JedisSeesion uses JedisPool, which only supports standalone scenarios. In production environments, users mostly use more complex deployment methods, such as sentinels, clusters, and master-slave setups. Furthermore, in a Java environment, users may use different Redis client implementations, such as
Jedis,Lettuce, andRedisson. If each is used independently, scaling up with different Redis client implementations would result ina lot of duplicate code. Moreover, naming conventions like JedisSeesion are unclear, as they are all essentially types of Redis clients.New Feature
agentscope-extensions-session-redismoduleThe newly added codes all have complete javadoc documentation and the
mvn testhas passed.Modify
New Usage
Jedis Usage Examples
Lettuce Usage Examples
Redisson Usage Example
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)