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

Introduce executor configuration to connection factories for Executor to be used with ClusterCommandExecutor #2669

Closed
wants to merge 4 commits into from

Conversation

jxblum
Copy link
Contributor

@jxblum jxblum commented Aug 10, 2023

Closes #2594

@jxblum jxblum added in: lettuce Lettuce driver in: jedis Jedis driver type: enhancement A general enhancement in: core Issues in core support labels Aug 10, 2023
@@ -51,6 +52,8 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon

private @Nullable Integer maxRedirects;

private @Nullable AsyncTaskExecutor executor;
Copy link
Member

Choose a reason for hiding this comment

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

RedisClusterConfiguration doesn't seem ideal to hold the executor. Our Redis…Configuration classes are intended to describe the endpoint(s) to connect to and provide specific connectivity options such as the password or redirection limit that are used by the clients directly.

ClusterCommandExecutor is a Spring Data concept. The alternative of moving the executor into …ClientConfiguration seems also not ideal because the executor isn't required by the client.

How about adding executor as property to [Jedis|Lettuce]ConnectionFactory directly? We have a few properties already, that are factory-specific (convertPipelineAndTxResults, shareNativeConnection, pipeliningFlushPolicy)? While the executor is only required for clustering operations, this change would give us the opportunity to revise its purpose along the lines of a "general purpose executor for asynchronous activity such as running multiple commands concurrently".

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

+1 for moving the executor to the connection factory.

@mp911de mp911de self-assigned this Aug 17, 2023
@mp911de mp911de removed the in: core Issues in core support label Aug 17, 2023
@mp911de mp911de added this to the 3.2 M2 (2023.1.0) milestone Aug 17, 2023
Organize source code and cleanup compiler warnings.

See #2594
Original pull request: #2669
This change allows users to leverage the VirtualThread facilities and AsyncTaskExecutor implementations provided in and by the core Spring Framework as part of our Loom support theme.

Closes #2594
Original pull request: #2669
mp911de added a commit that referenced this pull request Aug 17, 2023
Move executor from ClusterConfiguration to connection factories as the executor is a Spring concept that isn't tied to endpoint details or the client config.

Reorder static factory methods after constructors and property accessors after static factory methods. Inline single-line single-use methods that aren't intended as extension hooks for easier readability.

Remove NonNull annotations as default non-nullability is defined on the package level.

Simplify tests to use integration tests to avoid excessive mocking.

See #2594
Original pull request: #2669
mp911de added a commit that referenced this pull request Aug 17, 2023
Move executor from ClusterConfiguration to connection factories as the executor is a Spring concept that isn't tied to endpoint details or the client config.

Reorder static factory methods after constructors and property accessors after static factory methods. Inline single-line single-use methods that aren't intended as extension hooks for easier readability.

Remove NonNull annotations as default non-nullability is defined on the package level.

Simplify tests to use integration tests to avoid excessive mocking.

See #2594
Original pull request: #2669
Move executor from ClusterConfiguration to connection factories as the executor is a Spring concept that isn't tied to endpoint details or the client config.

Reorder static factory methods after constructors and property accessors after static factory methods. Inline single-line single-use methods that aren't intended as extension hooks for easier readability.

Disable TaskExecutor disposal on ClusterCommandExecutor.destroy().

Remove NonNull annotations as default non-nullability is defined on the package level.

Simplify tests to use integration tests to avoid excessive mocking.

See #2594
Original pull request: #2669
mp911de pushed a commit that referenced this pull request Aug 17, 2023
Organize source code and cleanup compiler warnings.

See #2594
Original pull request: #2669
mp911de pushed a commit that referenced this pull request Aug 17, 2023
This change allows users to leverage the VirtualThread facilities and AsyncTaskExecutor implementations provided in and by the core Spring Framework as part of our Loom support theme.

Closes #2594
Original pull request: #2669
mp911de added a commit that referenced this pull request Aug 17, 2023
Move executor from ClusterConfiguration to connection factories as the executor is a Spring concept that isn't tied to endpoint details or the client config.

Reorder static factory methods after constructors and property accessors after static factory methods. Inline single-line single-use methods that aren't intended as extension hooks for easier readability.

Disable TaskExecutor disposal on ClusterCommandExecutor.destroy().

Remove NonNull annotations as default non-nullability is defined on the package level.

Simplify tests to use integration tests to avoid excessive mocking.

See #2594
Original pull request: #2669
@mp911de
Copy link
Member

mp911de commented Aug 17, 2023

That's merged and polished now. Going forward, we should limit our polishing commits not to outweigh the actual change and if we want to apply larger cleanups, then it is better to handle these as separate tickets that can be backported. I'm guilty here as well.

@mp911de mp911de closed this Aug 17, 2023
@jxblum
Copy link
Contributor Author

jxblum commented Aug 17, 2023

@mp911de & @christophstrobl - I never had a chance to respond to the feedback on this PR & review, so I am not sure why we went ahead and merged this without completing the process. AFAICT, this was not time critical and certainly wasn't acted on with consensus. Rather, it seems we pushed this along to cram it into the release tomorrow (2023.1.0-M2; Fri, 2023-Aug-18), when we still have another scheduled milestone release (2023.1.0-M3) in September (Fri, 2023-Sept-15).

IMO, the Executor should NOT be a property of the (Jedis/Lettuce) connection factories because the connection factories have no business (purpose or use) for the Executor. Worse yet, we now maintain a reference to the Executor in 2 places, here and here.

In general, the component that requires, refers to and uses a collaborator (for example, like the Executor) should be responsible for managing the lifecycle of the collaborator.

With respect to configuration, I don't understand what you mean by this statement:

The alternative of moving the executor into …ClientConfiguration seems also not ideal because the executor isn't required by the client.

Spring Data Redis is all client-side. There is no SD Redis for a Redis server, in the purest sense, which was something SD GemFire/Geode actually did support (i.e. SD GemFire/Geode could be and was used on the server-side).

To my understanding, the ClusterCommandExecutor is used by the "client" to execute, or direct Redis commands to the appropriate (server) nodes in the Redis cluster (I assume based on "interest", i.e. based on the data/shard maintained by a Redis node for which the command was intended??). Even the Javadoc alludes to this component being client-directed.

Perhaps what would have been better in this case is a Strategy interface for how to "resolve" the "configured" Executor used by the ClusterCommandsExecutor. In this manner the Strategy interface can either provide an Executor directly, or indirectly, such as through the BeanFactory, or any other source for that matter.

The implementation of, say, the ExecutorResolver Strategy interface (or any appropriately named interface, and perhaps even a type of Suppler<AsyncTaskExecutor>, or even Spring ObjectProvider<AsyncTaskExecutor> (Javadoc)) could be responsible for managing single instances, new instances on request, changes to instance at runtime, whatever.

In any case, I don't agree with our current arrangement, and I think we should revisit this at some point.

@jxblum jxblum deleted the issue/2594 branch October 12, 2023 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: jedis Jedis driver in: lettuce Lettuce driver type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce executor configuration to connection factories for Executor to be used with ClusterCommandExecutor
3 participants