Skip to content

Commit

Permalink
Add support for client id command #1197
Browse files Browse the repository at this point in the history
Original pull request: #1230.
  • Loading branch information
dengliming authored and mp911de committed Feb 21, 2020
1 parent 1b26275 commit 1e25abf
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ public RedisFuture<String> clientList() {
return dispatch(commandBuilder.clientList());
}

@Override
public RedisFuture<Long> clientId() {
return dispatch(commandBuilder.clientId());
}

@Override
public RedisFuture<String> clientPause(long timeout) {
return dispatch(commandBuilder.clientPause(timeout));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public Mono<String> clientList() {
return createMono(commandBuilder::clientList);
}

@Override
public Mono<Long> clientId() {
return createMono(commandBuilder::clientId);
}

@Override
public Mono<String> clientPause(long timeout) {
return createMono(() -> commandBuilder.clientPause(timeout));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ Command<K, V, String> clientList() {
return createCommand(CLIENT, new StatusOutput<>(codec), args);
}

Command<K, V, Long> clientId() {
CommandArgs<K, V> args = new CommandArgs<>(codec).add(ID);
return createCommand(CLIENT, new IntegerOutput<>(codec), args);
}

Command<K, V, String> clientPause(long timeout) {
CommandArgs<K, V> args = new CommandArgs<>(codec).add(PAUSE).add(timeout);
return createCommand(CLIENT, new StatusOutput<>(codec), args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ public interface RedisServerAsyncCommands<K, V> {
*/
RedisFuture<String> clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
RedisFuture<Long> clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ public interface RedisServerReactiveCommands<K, V> {
*/
Mono<String> clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
Mono<Long> clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public interface RedisServerCommands<K, V> {
*/
String clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
Long clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public interface NodeSelectionServerAsyncCommands<K, V> {
*/
AsyncExecutions<String> clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
AsyncExecutions<Long> clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public interface NodeSelectionServerCommands<K, V> {
*/
Executions<String> clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
Executions<Long> clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public interface RedisServerCommands<K, V> {
*/
String clientList();

/**
* Get the id of the current connection.
*
* @return Long The command just returns the ID of the current connection. Every connection ID has certain guarantees
*/
Long clientId();

/**
* Returns an array reply of details about all Redis commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ void clientUnblock() throws InterruptedException {
assertThat(blocked.getError()).contains("UNBLOCKED client unblocked");
}

@Test
void clientId() {
assertThat(redis.clientId()).isNotNull();
}

@Test
void commandCount() {
assertThat(redis.commandCount()).isGreaterThan(100);
Expand Down

0 comments on commit 1e25abf

Please sign in to comment.