Skip to content

Conversation

@atakavci
Copy link
Collaborator

@atakavci atakavci commented Nov 7, 2025

This PR introduces a new Delegating<T> interface and refactors RedisClient to support better extensibility.

New Delegating<T> Interface

Added a generic interface for classes that wrap/delegate to another object

Updated Wrapper Classes

CommandListenerWriter now implements Delegating<RedisChannelWriter>
CommandExpiryWriter now implements Delegating<RedisChannelWriter>

RedisClient Extensibility
  • Added protected factory methods:
    • createEndpoint() - Creates DefaultEndpoint instances
    • createPubSubEndpoint() - Creates PubSubEndpoint instances
  • Replaced direct new DefaultEndpoint() calls with factory method calls
  • Allows subclasses to customize endpoint creation behavior

@atakavci atakavci self-assigned this Nov 7, 2025
@atakavci atakavci added the type: improvement An improvement to the existing implementation label Nov 7, 2025
@atakavci atakavci changed the title Improve extensibility that is needed for automatic-failover feature [automatic-failover] Improve extensibility that is needed for automatic-failover feature Nov 7, 2025
@atakavci atakavci requested a review from Copilot November 7, 2025 09:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a generic Delegating<T> interface to enable consistent unwrapping of delegating wrappers in the codebase. The main changes include:

  • Added a new Delegating<T> interface with getDelegate() and unwrap() methods for recursive unwrapping
  • Updated CommandExpiryWriter and CommandListenerWriter to implement the Delegating<RedisChannelWriter> interface
  • Refactored RedisClient to use factory methods (createEndpoint() and createPubSubEndpoint()) for better extensibility
  • Fixed a redundant cast in NodeSelectionInvocationHandler for the reactive executions path

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Delegating.java New interface providing a standard way to access and recursively unwrap delegates
CommandExpiryWriter.java Implements Delegating<RedisChannelWriter> to enable generic unwrapping
CommandListenerWriter.java Implements Delegating<RedisChannelWriter> to enable generic unwrapping
RedisClient.java Extracted endpoint creation into protected factory methods for subclass customization
NodeSelectionInvocationHandler.java Removed redundant cast when creating ReactiveExecutionsImpl

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (executionModel == ExecutionModel.REACTIVE) {
Map<RedisClusterNode, CompletionStage<? extends Publisher<?>>> reactiveExecutions = (Map) executions;
return new ReactiveExecutionsImpl<>(reactiveExecutions);
return new ReactiveExecutionsImpl<>((Map) reactiveExecutions);
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The double cast pattern (Map) reactiveExecutions where reactiveExecutions is already cast on line 180 is redundant. While this change removes one level of casting, there's still an unchecked cast being performed. Consider whether the ReactiveExecutionsImpl constructor signature can be updated to accept Map<RedisClusterNode, CompletionStage<? extends Publisher<?>>> directly to eliminate the need for unsafe casts.

Suggested change
return new ReactiveExecutionsImpl<>((Map) reactiveExecutions);
return new ReactiveExecutionsImpl<>(reactiveExecutions);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement An improvement to the existing implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant