Skip to content

Commit

Permalink
Update to Vert.x 4.3.1
Browse files Browse the repository at this point in the history
Vert.x 4.3.1 Redis clients has a few API breakage. This commit works around them.

In addition, Redis 7.0 dropped the host and post commands. They are now removed from the API (the user can still use a custom command, but these commands were deprecated for a long time)
  • Loading branch information
cescoffier committed Jun 25, 2022
1 parent a8042d7 commit 552f97b
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 81 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Expand Up @@ -51,7 +51,7 @@
<smallrye-context-propagation.version>1.2.2</smallrye-context-propagation.version>
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
<smallrye-reactive-types-converter.version>2.7.0</smallrye-reactive-types-converter.version>
<smallrye-mutiny-vertx-binding.version>2.22.0</smallrye-mutiny-vertx-binding.version>
<smallrye-mutiny-vertx-binding.version>2.23.0</smallrye-mutiny-vertx-binding.version>
<smallrye-reactive-messaging.version>3.17.0</smallrye-reactive-messaging.version>
<smallrye-stork.version>1.1.2</smallrye-stork.version>
<jakarta.activation.version>1.2.1</jakarta.activation.version>
Expand Down
Expand Up @@ -11,7 +11,7 @@ public class RedisTestResource implements QuarkusTestResourceLifecycleManager {

static GenericContainer<?> server = new GenericContainer<>(
DockerImageName.parse("redis:7-alpine"))
.withExposedPorts(6379);
.withExposedPorts(6379);

@Override
public Map<String, String> start() {
Expand Down
Expand Up @@ -132,8 +132,6 @@ public interface RedisClient {

Response hmset(List<String> args);

Response host(List<String> args);

Response hscan(List<String> args);

Response hset(List<String> args);
Expand Down Expand Up @@ -220,8 +218,6 @@ public interface RedisClient {

Response ping(List<String> args);

Response post(List<String> args);

Response psetex(String arg0, String arg1, String arg2);

Response psubscribe(List<String> args);
Expand Down
Expand Up @@ -263,10 +263,6 @@ static ReactiveRedisClient createClient(String name) {

Response hmsetAndAwait(List<String> args);

Uni<Response> host(List<String> args);

Response hostAndAwait(List<String> args);

Uni<Response> hscan(List<String> args);

Response hscanAndAwait(List<String> args);
Expand Down Expand Up @@ -439,10 +435,6 @@ static ReactiveRedisClient createClient(String name) {

Response pingAndAwait(List<String> args);

Uni<Response> post(List<String> args);

Response postAndAwait(List<String> args);

Uni<Response> psetex(String arg0, String arg1, String arg2);

Response psetexAndAwait(String arg0, String arg1, String arg2);
Expand Down
Expand Up @@ -321,22 +321,22 @@ public Response existsAndAwait(List<String> args) {

@Override
public Uni<Response> expire(String arg0, String arg1) {
return redisAPI.expire(arg0, arg1);
return redisAPI.expire(List.of(arg0, arg1));
}

@Override
public Response expireAndAwait(String arg0, String arg1) {
return redisAPI.expireAndAwait(arg0, arg1);
return redisAPI.expireAndAwait(List.of(arg0, arg1));
}

@Override
public Uni<Response> expireat(String arg0, String arg1) {
return redisAPI.expireat(arg0, arg1);
return redisAPI.expireat(List.of(arg0, arg1));
}

@Override
public Response expireatAndAwait(String arg0, String arg1) {
return redisAPI.expireatAndAwait(arg0, arg1);
return redisAPI.expireatAndAwait(List.of(arg0, arg1));
}

@Override
Expand Down Expand Up @@ -579,16 +579,6 @@ public Response hmsetAndAwait(List<String> args) {
return redisAPI.hmsetAndAwait(args);
}

@Override
public Uni<Response> host(List<String> args) {
return redisAPI.host(args);
}

@Override
public Response hostAndAwait(List<String> args) {
return redisAPI.hostAndAwait(args);
}

@Override
public Uni<Response> hscan(List<String> args) {
return redisAPI.hscan(args);
Expand Down Expand Up @@ -941,22 +931,22 @@ public Response persistAndAwait(String arg0) {

@Override
public Uni<Response> pexpire(String arg0, String arg1) {
return redisAPI.pexpire(arg0, arg1);
return redisAPI.pexpire(List.of(arg0, arg1));
}

@Override
public Response pexpireAndAwait(String arg0, String arg1) {
return redisAPI.pexpireAndAwait(arg0, arg1);
return redisAPI.pexpireAndAwait(List.of(arg0, arg1));
}

@Override
public Uni<Response> pexpireat(String arg0, String arg1) {
return redisAPI.pexpireat(arg0, arg1);
return redisAPI.pexpireat(List.of(arg0, arg1));
}

@Override
public Response pexpireatAndAwait(String arg0, String arg1) {
return redisAPI.pexpireatAndAwait(arg0, arg1);
return redisAPI.pexpireatAndAwait(List.of(arg0, arg1));
}

@Override
Expand Down Expand Up @@ -1019,16 +1009,6 @@ public Response pingAndAwait(List<String> args) {
return redisAPI.pingAndAwait(args);
}

@Override
public Uni<Response> post(List<String> args) {
return redisAPI.post(args);
}

@Override
public Response postAndAwait(List<String> args) {
return redisAPI.postAndAwait(args);
}

@Override
public Uni<Response> psetex(String arg0, String arg1, String arg2) {
return redisAPI.psetex(arg0, arg1, arg2);
Expand Down Expand Up @@ -1801,12 +1781,12 @@ public Response xrevrangeAndAwait(List<String> args) {

@Override
public Uni<Response> xsetid(String arg0, String arg1) {
return redisAPI.xsetid(arg0, arg1);
return redisAPI.xsetid(List.of(arg0, arg1));
}

@Override
public Response xsetidAndAwait(String arg0, String arg1) {
return redisAPI.xsetidAndAwait(arg0, arg1);
return redisAPI.xsetidAndAwait(List.of(arg0, arg1));
}

@Override
Expand Down
Expand Up @@ -174,12 +174,12 @@ public Response exists(List<String> args) {

@Override
public Response expire(String arg0, String arg1) {
return await(redisAPI.expire(arg0, arg1));
return await(redisAPI.expire(List.of(arg0, arg1)));
}

@Override
public Response expireat(String arg0, String arg1) {
return await(redisAPI.expireat(arg0, arg1));
return await(redisAPI.expireat(List.of(arg0, arg1)));
}

@Override
Expand Down Expand Up @@ -302,11 +302,6 @@ public Response hmset(List<String> args) {
return await(redisAPI.hmset(args));
}

@Override
public Response host(List<String> args) {
return await(redisAPI.host(args));
}

@Override
public Response hscan(List<String> args) {
return await(redisAPI.hscan(args));
Expand Down Expand Up @@ -484,12 +479,12 @@ public Response persist(String arg0) {

@Override
public Response pexpire(String arg0, String arg1) {
return await(redisAPI.pexpire(arg0, arg1));
return await(redisAPI.pexpire(List.of(arg0, arg1)));
}

@Override
public Response pexpireat(String arg0, String arg1) {
return await(redisAPI.pexpireat(arg0, arg1));
return await(redisAPI.pexpireat(List.of(arg0, arg1)));
}

@Override
Expand Down Expand Up @@ -522,11 +517,6 @@ public Response ping(List<String> args) {
return await(redisAPI.ping(args));
}

@Override
public Response post(List<String> args) {
return await(redisAPI.post(args));
}

@Override
public Response psetex(String arg0, String arg1, String arg2) {
return await(redisAPI.psetex(arg0, arg1, arg2));
Expand Down Expand Up @@ -914,7 +904,7 @@ public Response xrevrange(List<String> args) {

@Override
public Response xsetid(String arg0, String arg1) {
return await(redisAPI.xsetid(arg0, arg1));
return await(redisAPI.xsetid(List.of(arg0, arg1)));
}

@Override
Expand Down
Expand Up @@ -5,6 +5,8 @@
import static io.smallrye.mutiny.helpers.ParameterValidation.nonNull;
import static io.smallrye.mutiny.helpers.ParameterValidation.positive;
import static io.smallrye.mutiny.helpers.ParameterValidation.positiveOrZero;
import static io.vertx.mutiny.redis.client.Command.EXPIRETIME;
import static io.vertx.mutiny.redis.client.Command.PEXPIRETIME;

import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand All @@ -28,10 +30,6 @@ class AbstractKeyCommands<K> extends AbstractRedisCommands {

protected final Class<K> typeOfKey;

// TODO Remove after update to Vert.x 4.3
public static final Command EXPIRETIME = Command.create("expiretime");
public static final Command PEXPIRETIME = Command.create("pexpiretime");

AbstractKeyCommands(RedisCommandExecutor redis, Class<K> k) {
super(redis, new Marshaller(k));
this.typeOfKey = k;
Expand Down Expand Up @@ -240,25 +238,25 @@ Uni<Response> _rename(K key, K newKey) {
nonNull(newKey, "newKey");
return execute(RedisCommand.of(Command.RENAME)
.put(marshaller.encode(key)).put(marshaller.encode(newKey)))
.onFailure().transform(t -> {
if (t.getMessage().equalsIgnoreCase("ERR no such key")) {
return new NoSuchElementException(new String(marshaller.encode(key), StandardCharsets.UTF_8));
}
return t;
});
.onFailure().transform(t -> {
if (t.getMessage().equalsIgnoreCase("ERR no such key")) {
return new NoSuchElementException(new String(marshaller.encode(key), StandardCharsets.UTF_8));
}
return t;
});
}

Uni<Response> _renamenx(K key, K newKey) {
nonNull(key, "key");
nonNull(newKey, "newKey");
return execute(RedisCommand.of(Command.RENAMENX)
.put(marshaller.encode(key)).put(marshaller.encode(newKey)))
.onFailure().transform(t -> {
if (t.getMessage().equalsIgnoreCase("ERR no such key")) {
return new NoSuchElementException(new String(marshaller.encode(key), StandardCharsets.UTF_8));
}
return t;
});
.onFailure().transform(t -> {
if (t.getMessage().equalsIgnoreCase("ERR no such key")) {
return new NoSuchElementException(new String(marshaller.encode(key), StandardCharsets.UTF_8));
}
return t;
});
}

ReactiveCursor<Set<K>> scan() {
Expand Down
Expand Up @@ -21,7 +21,7 @@ public class DatasourceTestBase {

static GenericContainer<?> server = new GenericContainer<>(
DockerImageName.parse("redis:7-alpine"))
.withExposedPorts(6379);
.withExposedPorts(6379);

@BeforeAll
static void init() {
Expand Down
Expand Up @@ -345,7 +345,7 @@ void georadiusWithNullArgs() {

assertThatThrownBy(
() -> geo.georadius(key, VALENCE_LONGITUDE, VALENCE_LATITUDE, 5, GeoUnit.KM, (GeoRadiusStoreArgs<String>) null))
.isInstanceOf(IllegalArgumentException.class);
.isInstanceOf(IllegalArgumentException.class);
}

@Test
Expand Down
Expand Up @@ -255,12 +255,12 @@ void unsubscribe() {

subscriber.unsubscribe(channel);

awaitNoMoreActiveChannels();

pubsub.publish(channel, new Person("leia", "skywalker"));

Awaitility.await().pollDelay(Duration.ofMillis(10)).until(() -> people.size() == 1);

awaitNoMoreActiveChannels();

}

@Test
Expand Down Expand Up @@ -296,6 +296,8 @@ void unsubscribeOne() {
Awaitility.await().pollDelay(Duration.ofMillis(10)).until(() -> people.size() > 2);

subscriber.unsubscribe("bar");

awaitNoMoreActiveChannels();
}

@Test
Expand All @@ -308,6 +310,7 @@ void unsubscribePattern() {

subscriber.unsubscribe(channel + "*");

awaitNoMoreActiveChannels();
pubsub.publish(channel + "1", new Person("leia", "skywalker"));

Awaitility.await().pollDelay(Duration.ofMillis(10)).until(() -> people.size() == 1);
Expand All @@ -323,9 +326,12 @@ void unsubscribeAllPatterns() {

subscriber.unsubscribe();

awaitNoMoreActiveChannels();

pubsub.publish(channel + "1", new Person("leia", "skywalker"));

Awaitility.await().pollDelay(Duration.ofMillis(10)).until(() -> people.size() == 1);

}

@Test
Expand All @@ -342,6 +348,8 @@ void unsubscribeOnePattern() {
pubsub.publish("bar4", new Person("luke", "skywalker"));

subscriber.unsubscribe("bar*");

awaitNoMoreActiveChannels();
}

@Test
Expand All @@ -358,6 +366,8 @@ void utf8ChannelAndContent() {
Assertions.assertThat(people).containsExactly(new Person(name, name));

subscriber.unsubscribe();

awaitNoMoreActiveChannels();
}

}
Expand Up @@ -183,7 +183,7 @@ void zcount() {

assertThat(setOfPlaces.zadd(key, new ScoredValue<>(Place.crussol, 1.0), new ScoredValue<>(Place.grignan, 2.0),
new ScoredValue<>(Place.suze, 2.1)))
.isEqualTo(3);
.isEqualTo(3);

assertThat(setOfPlaces.zcount(key, ScoreRange.from(1.0, 3.0))).isEqualTo(3);
assertThat(setOfPlaces.zcount(key, ScoreRange.from(1.0, 2.0))).isEqualTo(2);
Expand Down Expand Up @@ -534,7 +534,7 @@ void zrevrangestorebyscore() {
assertThat(
setOfPlaces.zrangestorebyscore("key1", key, new ScoreRange<>(2.0, true, 1.0, false),
new ZRangeArgs().rev().limit(0, 2)))
.isEqualTo(1);
.isEqualTo(1);
assertThat(setOfPlaces.zrange("key1", 0, 2)).isEqualTo(List.of(Place.grignan));
}

Expand Down

0 comments on commit 552f97b

Please sign in to comment.