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

Add support for CommandListeners #1424

Closed

Conversation

sokomishalov
Copy link
Collaborator

Draft for #1382

@sokomishalov sokomishalov changed the title implementing command handlers implement command handlers Sep 21, 2020
@codecov
Copy link

codecov bot commented Sep 21, 2020

Codecov Report

Merging #1424 into main will increase coverage by 0.00%.
The diff coverage is 61.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##               main    #1424    +/-   ##
==========================================
  Coverage     78.81%   78.82%            
- Complexity     6206     6261    +55     
==========================================
  Files           461      468     +7     
  Lines         20741    21039   +298     
  Branches       2283     2325    +42     
==========================================
+ Hits          16348    16584   +236     
- Misses         3337     3388    +51     
- Partials       1056     1067    +11     
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/lettuce/core/CommandListener.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...va/io/lettuce/core/cluster/RedisClusterClient.java 85.62% <0.00%> (-2.15%) 112.00 <0.00> (ø)
...java/io/lettuce/core/resource/ClientResources.java 66.66% <ø> (ø) 2.00 <0.00> (ø)
src/main/java/io/lettuce/core/RedisClient.java 88.28% <33.33%> (-1.42%) 91.00 <0.00> (+1.00) ⬇️
...in/java/io/lettuce/core/CommandListenerWriter.java 54.09% <54.09%> (ø) 6.00 <6.00> (?)
...tuce/core/models/events/CommandSucceededEvent.java 71.42% <71.42%> (ø) 2.00 <2.00> (?)
...o/lettuce/core/models/events/CommandBaseEvent.java 83.33% <83.33%> (ø) 2.00 <2.00> (?)
...va/io/lettuce/core/CommandListenerMulticaster.java 93.75% <93.75%> (ø) 7.00 <7.00> (?)
...lettuce/core/models/events/CommandFailedEvent.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)
...ettuce/core/models/events/CommandStartedEvent.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45e8307...961eccf. Read the comment docs.

Copy link
Collaborator

@mp911de mp911de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this issue. I left a few comments about topics that we should address.

Please also note that we should have copyright headers on each new class with 2020 as inception year.

src/main/java/io/lettuce/core/RedisClient.java Outdated Show resolved Hide resolved
src/main/java/io/lettuce/core/RedisClient.java Outdated Show resolved Hide resolved
@sokomishalov sokomishalov force-pushed the feature/command-handlers branch 6 times, most recently from 4f7ad04 to 3d73717 Compare September 22, 2020 00:37
@sokomishalov sokomishalov marked this pull request as ready for review September 22, 2020 00:39
@mp911de mp911de added this to the 6.1 M1 milestone Sep 28, 2020
@mp911de
Copy link
Collaborator

mp911de commented Sep 28, 2020

Targetting this PR for 6.1 since 6.0 will be released in the next few days.

@sokomishalov sokomishalov force-pushed the feature/command-handlers branch from 3d73717 to 96677eb Compare September 28, 2020 11:06
@sokomishalov
Copy link
Collaborator Author

Ok. Fixed @since javadoc lines for APIs.

@sokomishalov sokomishalov force-pushed the feature/command-handlers branch 2 times, most recently from e98c516 to 177eec7 Compare October 2, 2020 10:25
@sokomishalov sokomishalov force-pushed the feature/command-handlers branch from 177eec7 to f968a3e Compare October 26, 2020 12:30
@sokomishalov sokomishalov force-pushed the feature/command-handlers branch from f968a3e to 961eccf Compare November 1, 2020 23:35
@mp911de mp911de self-assigned this Nov 8, 2020
@mp911de
Copy link
Collaborator

mp911de commented Nov 8, 2020

I started working on merging this PR. It provides a lot of value, but the real design challenges surfaced when trying to come up with a configuration model. Listeners aren't tied to ClientOptions or ClientResources. Since AbstractRedisClient already provides a listener API, I decided to add an overload accepting CommandListener.

I also removed generics from the command events to make things simpler. Let's see how this goes. I also noticed that introducing CommandListenerWriter breaks timeout overrides as setTimeout in RedisChannelHandler checks whether the writer is a CommandExpiryWriter.

The changes are exciting and the implementation makes a lot of sense. With the merge some shortcomings of the current implementation of RedisClient become apparent (see #1511). Also, redirected Cluster commands are reported multiple times with started/success events since each connection applies a listener. Not sure how to feel about it yet.

@mp911de mp911de added the type: feature A new feature label Nov 8, 2020
mp911de pushed a commit that referenced this pull request Nov 8, 2020
mp911de added a commit that referenced this pull request Nov 8, 2020
Move events from models.events to event.command. Move CommandListener configuration from ClientResources to AbstractRedisClient.addListener. Consider changed writer chain in RedisChannelHandler.setTimeout. Add tests for standalone and Redis Cluster operations. Remove generics from command events to simplify interaction and listener implementation.

Replace generic ExecutionException with ExceptionFactory usage.

Original pull request: #1424.
@mp911de
Copy link
Collaborator

mp911de commented Nov 8, 2020

Thank you for your contribution. That's merged and polished now.

@mp911de mp911de closed this Nov 8, 2020
@mp911de mp911de changed the title implement command handlers Add support for CommandListeners Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants