-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 client parameter when creating Vertx Redis client #43454
Conversation
mcruzdev
commented
Sep 24, 2024
•
edited by geoand
Loading
edited by geoand
- Fixes: Redis client list command returns empty name ("name=") when i set @RedisClientName #43167
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Show resolved
Hide resolved
3305a7a
to
e90d560
Compare
@@ -107,6 +113,32 @@ public static Redis create(String name, Vertx vertx, RedisClientConfig config, T | |||
return Redis.createClient(vertx, options); | |||
} | |||
|
|||
public static String generateConnectionString(String clientName, URI uri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed the client name to URL-encodable. It may not be correct. If you have a client name for observability purposes (checking the connection on Redis, for example), your client name was arbitrarily modified.
It would be better to encode the client name correctly using URL encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution (easier) would be to document the transformation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ladicek what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the transformation here is a big deal, but there should be some documentation indeed.
private final RedisDataSource client11; | ||
|
||
@Inject | ||
public RedisClientResource(@RedisClientName("quarkiverse") RedisDataSource ds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to test the various characters that are getting transformed.
28b7d77
to
9df660f
Compare
Hi @cescoffier, @Ladicek as mentioned in Zulip (there is no way to link the chat) I changed the way to define a client. We only have the option to set a client name after Redis 6, as Redis version 5 does not allow configuration via connection string. Another interesting thing is that we don’t need to worry much about special characters, we skip the URL encoding. I'm not sure if recording this call to Redis before the application starts is the best solution. I'm open to suggestions and would appreciate any recommendations. |
String clientName = actualConfig.clientName().orElse(name); | ||
redisClientAndApi.redis.send(Request.cmd(Command.CLIENT, new Object[] { | ||
"SETNAME", clientName | ||
})).subscribe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach will lead to race conditions. The execution of the command is async and thus, someone using the client immediately to emit another command may race with this (and may not have the client set).
This approach would work but we would need to make sure
- Redis is available
- Every other commands are enqueued until this one terminate successfully
5619a91
to
fd1878f
Compare
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
...s-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisClientConfig.java
Outdated
Show resolved
Hide resolved
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
...is-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java
Outdated
Show resolved
Hide resolved
12fc51f
to
90c2a2a
Compare
🎊 PR Preview e2c1d31 has been successfully built and deployed to https://quarkus-pr-main-43454-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9275bf5
to
ec57afa
Compare
This comment has been minimized.
This comment has been minimized.
ec57afa
to
806e751
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @Ladicek WDYT?
541a9c8
to
d4b08d0
Compare
.../redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/RedisClientRecorder.java
Outdated
Show resolved
Hide resolved
...lient/runtime/src/test/java/io/quarkus/redis/runtime/client/VertxRedisClientFactoryTest.java
Outdated
Show resolved
Hide resolved
...s-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisClientConfig.java
Outdated
Show resolved
Hide resolved
...s-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisClientConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, requested just a few tiny changes.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Can you squash your commits? Thanks! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
done @cescoffier! |
Status for workflow
|
Status for workflow
|
Thanks! |