From 68efa444c9744b547c4b5df67c641a0b18a9895b Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 27 Dec 2024 09:24:27 +0300 Subject: [PATCH] refactoring --- .../org/redisson/command/CommandAsyncExecutor.java | 13 +++++++++---- .../org/redisson/command/CommandAsyncService.java | 2 +- .../connection/MasterSlaveConnectionManager.java | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncExecutor.java b/redisson/src/main/java/org/redisson/command/CommandAsyncExecutor.java index 7ffd3fcda..ff9cf9aa4 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncExecutor.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncExecutor.java @@ -48,7 +48,7 @@ public interface CommandAsyncExecutor { CommandAsyncExecutor copy(boolean trackChanges); RedissonObjectBuilder getObjectBuilder(); - + ConnectionManager getConnectionManager(); ServiceManager getServiceManager(); @@ -62,7 +62,7 @@ public interface CommandAsyncExecutor { V get(RFuture future); V get(CompletableFuture future); - + V getInterrupted(RFuture future) throws InterruptedException; V getInterrupted(CompletableFuture future) throws InterruptedException; @@ -70,7 +70,7 @@ public interface CommandAsyncExecutor { RFuture writeAsync(RedisClient client, Codec codec, RedisCommand command, Object... params); RFuture writeAsync(MasterSlaveEntry entry, Codec codec, RedisCommand command, Object... params); - + RFuture writeAsync(byte[] key, Codec codec, RedisCommand command, Object... params); RFuture writeAsync(ByteBuf key, Codec codec, RedisCommand command, Object... params); @@ -168,4 +168,9 @@ public interface CommandAsyncExecutor { CommandBatchService createCommandBatchService(BatchOptions options); -} + static CommandAsyncExecutor create(ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, + RedissonObjectBuilder.ReferenceType referenceType) { + return new CommandAsyncService(connectionManager, objectBuilder, referenceType); + } + +} \ No newline at end of file diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index 1a276da25..983f3da7e 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -124,7 +124,7 @@ public class CommandAsyncService implements CommandAsyncExecutor { this.trackChanges = false; } - public CommandAsyncService(ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, + protected CommandAsyncService(ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, RedissonObjectBuilder.ReferenceType referenceType) { this.connectionManager = connectionManager; this.objectBuilder = objectBuilder; diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java index 24d902018..3048e9ad0 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java @@ -568,6 +568,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager { @Override public CommandAsyncExecutor createCommandExecutor(RedissonObjectBuilder objectBuilder, RedissonObjectBuilder.ReferenceType referenceType) { - return new CommandAsyncService(this, objectBuilder, referenceType); + return CommandAsyncExecutor.create(this, objectBuilder, referenceType); } }