Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support automatic namespacing #3781

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

sazzad16
Copy link
Collaborator

@sazzad16 sazzad16 commented Mar 20, 2024

Support automatic namespacing (key prefixing) by handler (key pre-processing) interface.

This is based on #3770 by @killergerbah

R-J Lim and others added 6 commits March 18, 2024 14:26
- Demonstrated automatic key-prefixing for all subclasses of
  UnifiedJedis: JedisCluster, JedisPooled, and JedisSentineled
- Key-prefixing is possible as long as the underlying CommandObjects can
  be customized.
- CommandObjects cannot use commandArguments in its constructor since
  in the specific case of key-prefixing, commandArguments depends on the
  child constructor running first. So we lose caching of argument-less
  CommandObjects.
- Based on this POC, the minimum changes required to jedis would be:
  - public constructors that allow UnifiedJedis and its subclasses to
    take a custom CommandObjects.
  - Consistent use of supplied CommandObjects throughout code (e.g. in
    Pipeline, Transaction, etc).
  - Removal of caching of argument-less CommandObjects in the
    constructor of CommandObjects.
- Applications can then supply CommandObjects with custom behavior as
  necessary. Sample classes that implement the behavior of prefixed keys,
  etc are provided but these can be supplied by the application as long
  as required constructors are available.
- Restore cached key-less commands in CommandObjects
- Support Transactions
- New constructors do not take CommandExecutor
- Requested JavaDoc regarding new constructors specifying RedisProtocol
- New classes moved into 'prefix' packages
- De-duplicate prefixing code
- Restore public Transaction constructor that was removed
- Use Connection.executeCommand instead of Connection.sendCommand
@killergerbah
Copy link

Pasting my thoughts from #3770:

Thank you. I like your approach because it uses composition instead of inheritance to achieve the same outcome. It also does not require modification of constructors of UnifiedJedis and all of its subclasses. From a caller point of view it is easier to use since it requires just setting the command key processor instead of picking the right constructor to use. I would be supportive of continuing with your branch.

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 86.41975% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 82.11%. Comparing base (2d42338) to head (4bb8198).
Report is 9 commits behind head on master.

❗ Current head 4bb8198 differs from pull request most recent head 9a86cce. Consider uploading reports for the commit 9a86cce to get more accurate results

Files Patch % Lines
...ts/jedis/util/PrefixedKeyArgumentPreProcessor.java 75.00% 3 Missing and 2 partials ⚠️
src/main/java/redis/clients/jedis/Transaction.java 84.61% 2 Missing ⚠️
...dis/clients/jedis/mcf/MultiClusterTransaction.java 0.00% 2 Missing ⚠️
.../java/redis/clients/jedis/ReliableTransaction.java 91.66% 0 Missing and 1 partial ⚠️
...ava/redis/clients/jedis/ShardedCommandObjects.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3781      +/-   ##
============================================
- Coverage     82.15%   82.11%   -0.04%     
- Complexity     6016     6035      +19     
============================================
  Files           301      302       +1     
  Lines         15273    15329      +56     
  Branches       1190     1198       +8     
============================================
+ Hits          12547    12588      +41     
- Misses         2159     2168       +9     
- Partials        567      573       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sazzad16 sazzad16 requested a review from gerzse March 21, 2024 09:04
@sazzad16 sazzad16 added this to the 5.2.0 milestone Mar 21, 2024
@sazzad16 sazzad16 changed the title Support automatic key prefixing by handler interface Support automatic namespacing by handler interface Mar 27, 2024
@sazzad16 sazzad16 changed the title Support automatic namespacing by handler interface Support automatic namespacing Mar 27, 2024
@sazzad16 sazzad16 requested review from uglide and removed request for gerzse April 3, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants