Skip to content

Commit

Permalink
Polishing #1538
Browse files Browse the repository at this point in the history
Tweak Javadoc. Remove UserRulesOutput in favor of introducing a model parser later on.
Switch Enum output to construct an enum set.
Reformat code. Update since tags.

Original pull request: #1602.
  • Loading branch information
mp911de committed Mar 2, 2021
1 parent 38fc408 commit e07128e
Show file tree
Hide file tree
Showing 44 changed files with 391 additions and 383 deletions.
1 change: 1 addition & 0 deletions src/main/asciidoc/new-features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Configuration of extended Keep-Alive options through `KeepAliveOptions` (only available for some transports/Java versions).
* Configuration of netty's `AddressResolverGroup` through `ClientResources`.
Uses `DnsAddressResolverGroup` when `netty-resolver-dns` is on the classpath.
* Add support for Redis ACL commands.

[[new-features.6-0-0]]
== What's new in Lettuce 6.0
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCode
}

@Override
public RedisFuture<List<AclCategory>> aclCat() {
public RedisFuture<Set<AclCategory>> aclCat() {
return dispatch(commandBuilder.aclCat());
}

@Override
public RedisFuture<List<CommandType>> aclCat(AclCategory category) {
public RedisFuture<Set<CommandType>> aclCat(AclCategory category) {
return dispatch(commandBuilder.aclCat(category));
}

Expand All @@ -105,7 +105,7 @@ public RedisFuture<String> aclGenpass(int bits) {
}

@Override
public RedisFuture<Map<String, Object>> aclGetuser(String username) {
public RedisFuture<List<Object>> aclGetuser(String username) {
return dispatch(commandBuilder.aclGetuser(username));
}

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import reactor.core.publisher.Flux;
Expand Down Expand Up @@ -111,13 +112,13 @@ private EventExecutorGroup getScheduler() {
}

@Override
public Flux<AclCategory> aclCat() {
return createDissolvingFlux(commandBuilder::aclCat);
public Mono<Set<AclCategory>> aclCat() {
return createMono(commandBuilder::aclCat);
}

@Override
public Flux<CommandType> aclCat(AclCategory category) {
return createDissolvingFlux(() -> commandBuilder.aclCat(category));
public Mono<Set<CommandType>> aclCat(AclCategory category) {
return createMono(() -> commandBuilder.aclCat(category));
}

@Override
Expand All @@ -136,7 +137,7 @@ public Mono<String> aclGenpass(int bits) {
}

@Override
public Mono<Map<String, Object>> aclGetuser(String username) {
public Mono<List<Object>> aclGetuser(String username) {
return createMono(() -> commandBuilder.aclGetuser(username));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/AclCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* Enum object describing Redis ACL categories.
*
* @since 6.1
* @author Mikhael Sokolov
* @since 6.1
*/
public enum AclCategory {

Expand Down Expand Up @@ -112,4 +112,4 @@ public enum AclCategory {
* scripting command
*/
SCRIPTING
}
}
10 changes: 5 additions & 5 deletions src/main/java/io/lettuce/core/AclSetuserArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
*/
package io.lettuce.core;

import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.ProtocolKeyword;
import static io.lettuce.core.protocol.CommandKeyword.*;

import java.util.ArrayList;
import java.util.List;

import static io.lettuce.core.protocol.CommandKeyword.*;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.ProtocolKeyword;

/**
* Argument list builder for the Redis <a href="https://redis.io/commands/acl-setuser">ACL SETUSER</a> command.
* <p>
* {@link AclSetuserArgs} is a mutable object and instances should be used only once to avoid shared mutable state.
*
* @author Mikhael Sokolov
* @since 6.2
* @since 6.1
*/
public class AclSetuserArgs implements CompositeArgument {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/CopyArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* {@link CopyArgs} is a mutable object and instances should be used only once to avoid shared mutable state.
*
* @author Bartek Kowalczyk
* @since 6.2
* @since 6.1
*/
public class CopyArgs implements CompositeArgument {

Expand Down
19 changes: 12 additions & 7 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
import io.lettuce.core.models.stream.PendingMessage;
import io.lettuce.core.models.stream.PendingMessages;
import io.lettuce.core.output.*;
import io.lettuce.core.protocol.*;
import io.lettuce.core.protocol.BaseRedisCommandBuilder;
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandKeyword;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.RedisCommand;

/**
* @param <K>
Expand Down Expand Up @@ -64,17 +69,17 @@ class RedisCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
super(codec);
}

Command<K, V, List<AclCategory>> aclCat() {
Command<K, V, Set<AclCategory>> aclCat() {
CommandArgs<K, V> args = new CommandArgs<>(codec);
args.add(CAT);
return createCommand(ACL, new EnumListOutput<>(codec, AclCategory.class), args);
return createCommand(ACL, new EnumSetOutput<>(codec, AclCategory.class, String::toUpperCase, it -> null), args);
}

Command<K, V, List<CommandType>> aclCat(AclCategory category) {
Command<K, V, Set<CommandType>> aclCat(AclCategory category) {
LettuceAssert.notNull(category, "Category " + MUST_NOT_BE_NULL);
CommandArgs<K, V> args = new CommandArgs<>(codec);
args.add(CAT).add(category.name().toLowerCase());
return createCommand(ACL, new EnumListOutput<>(codec, CommandType.class), args);
return createCommand(ACL, new EnumSetOutput<>(codec, CommandType.class, String::toUpperCase, it -> null), args);
}

Command<K, V, Long> aclDeluser(String... usernames) {
Expand All @@ -99,11 +104,11 @@ Command<K, V, String> aclGenpass(int bits) {
return createCommand(ACL, new StatusOutput<>(codec), args);
}

Command<K, V, Map<String, Object>> aclGetuser(String username) {
Command<K, V, List<Object>> aclGetuser(String username) {
LettuceAssert.notNull(username, "Username " + MUST_NOT_BE_NULL);
CommandArgs<K, V> args = new CommandArgs<>(codec);
args.add(GETUSER).add(username);
return createCommand(ACL, new UserRulesOutput<>(codec), args);
return createCommand(ACL, new NestedMultiOutput<>(codec), args);
}

Command<K, V, List<String>> aclList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package io.lettuce.core.api.async;

import java.util.List;
import java.util.Map;
import java.util.Set;

import io.lettuce.core.AclCategory;
import io.lettuce.core.AclSetuserArgs;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.protocol.CommandType;

import java.util.List;
import java.util.Map;

/**
* Asynchronous executed commands for the ACL-API.
*
* @author Mark Paluch
* @author Mikhael Sokolov
* @since 6.1
* @generated by io.lettuce.apigenerator.CreateAsyncApi
Expand All @@ -38,15 +38,15 @@ public interface RedisAclAsyncCommands<K, V> {
*
* @return List&lt;AclCategory&gt; a list of ACL categories or
*/
RedisFuture<List<AclCategory>> aclCat();
RedisFuture<Set<AclCategory>> aclCat();

/**
* The command shows all the Redis commands in the specified category.
*
* @param category the specified category
* @return List&lt;CommandType&gt; a list of commands inside a given category
*/
RedisFuture<List<CommandType>> aclCat(AclCategory category);
RedisFuture<Set<CommandType>> aclCat(AclCategory category);

/**
* Delete all the specified ACL users and terminate all the connections that are authenticated with such users.
Expand Down Expand Up @@ -77,7 +77,7 @@ public interface RedisAclAsyncCommands<K, V> {
* @param username the specified username
* @return Map&lt;String, Object&gt; a map of ACL rule definitions for the user.
*/
RedisFuture<Map<String, Object>> aclGetuser(String username);
RedisFuture<List<Object>> aclGetuser(String username);

/**
* The command shows the currently active ACL rules in the Redis server.
Expand Down Expand Up @@ -128,7 +128,7 @@ public interface RedisAclAsyncCommands<K, V> {
* Create an ACL user with the specified rules or modify the rules of an existing user.
*
* @param username the specified username
* @param rules rules
* @param setuserArgs rules
* @return String simple-string-reply OK or error message.
*/
RedisFuture<String> aclSetuser(String username, AclSetuserArgs setuserArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface RedisKeyAsyncCommands<K, V> {
* @param source the source.
* @param destination the destination.
* @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied.
* @since 6.2
* @since 6.1
*/
RedisFuture<Boolean> copy(K source, K destination);

Expand All @@ -61,7 +61,7 @@ public interface RedisKeyAsyncCommands<K, V> {
* @param destination the destination.
* @param copyArgs the copyArgs.
* @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied.
* @since 6.2
* @since 6.1
*/
RedisFuture<Boolean> copy(K source, K destination, CopyArgs copyArgs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
*
* @param keys the keys.
* @return List&lt;V&gt; array-reply list of elements.
* @since 6.2
* @since 6.1
*/
RedisFuture<List<V>> zdiff(K... keys);

Expand All @@ -213,7 +213,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
* @param destKey the dest key.
* @param srcKeys the src keys.
* @return Long the number of elements in the resulting sorted set at destination.
* @since 6.2
* @since 6.1
*/
RedisFuture<Long> zdiffstore(K destKey, K... srcKeys);

Expand All @@ -222,7 +222,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
*
* @param keys the keys.
* @return List&lt;V&gt; array-reply list of scored values.
* @since 6.2
* @since 6.1
*/
RedisFuture<List<ScoredValue<V>>> zdiffWithScores(K... keys);

Expand Down Expand Up @@ -765,7 +765,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
* @param srcKey the src key.
* @param range the lexicographical range.
* @return The number of elements in the resulting sorted set.
* @since 6.2
* @since 6.1
*/
RedisFuture<Long> zrangestorebylex(K dstKey, K srcKey, Range<? extends V> range, Limit limit);

Expand All @@ -777,7 +777,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
* @param srcKey the src key.
* @param range the score range.
* @return The number of elements in the resulting sorted set.
* @since 6.2
* @since 6.1
*/
RedisFuture<Long> zrangestorebyscore(K dstKey, K srcKey, Range<? extends Number> range, Limit limit);

Expand Down Expand Up @@ -1242,7 +1242,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
* @param srcKey the src key.
* @param range the lexicographical range.
* @return The number of elements in the resulting sorted set.
* @since 6.2
* @since 6.1
*/
RedisFuture<Long> zrevrangestorebylex(K dstKey, K srcKey, Range<? extends V> range, Limit limit);

Expand All @@ -1254,7 +1254,7 @@ public interface RedisSortedSetAsyncCommands<K, V> {
* @param srcKey the src key.
* @param range the score range.
* @return The number of elements in the resulting sorted set.
* @since 6.2
* @since 6.1
*/
RedisFuture<Long> zrevrangestorebyscore(K dstKey, K srcKey, Range<? extends Number> range, Limit limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
import java.util.List;
import java.util.Map;

import io.lettuce.core.*;
import io.lettuce.core.BitFieldArgs;
import io.lettuce.core.KeyValue;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.SetArgs;
import io.lettuce.core.StrAlgoArgs;
import io.lettuce.core.StringMatchResult;
import io.lettuce.core.output.KeyValueStreamingChannel;

/**
Expand Down Expand Up @@ -312,7 +317,7 @@ public interface RedisStringAsyncCommands<K, V> {
* @param key the key.
* @param value the value.
* @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist.
* @since 6.2
* @since 6.1
*/
RedisFuture<V> setGet(K key, V value);

Expand All @@ -323,7 +328,7 @@ public interface RedisStringAsyncCommands<K, V> {
* @param value the value.
* @param setArgs the command arguments.
* @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist.
* @since 6.2
* @since 6.1
*/
RedisFuture<V> setGet(K key, V value, SetArgs setArgs);

Expand Down
Loading

0 comments on commit e07128e

Please sign in to comment.