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 client id command #1230

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -182,6 +182,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 @@ -237,6 +237,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