Skip to content

Commit

Permalink
Align client connection - no default address.
Browse files Browse the repository at this point in the history
If the user didn't pass an address, that's a user error. We shouldn't
assume that they want to connect to localhost, considering that isn't
a common behavior.
  • Loading branch information
nihohit committed Jan 14, 2024
1 parent 2f901b0 commit a2da939
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public abstract class BaseClientConfiguration {
* list can be partial, as the client will attempt to map out the cluster and find all nodes. If
* the server is in standalone mode, only nodes whose addresses were provided will be used by the
* client. For example: <code>[ {address:sample-address-0001.use1.cache.amazonaws.com, port:6379},
* {address: sample-address-0002.use2.cache.amazonaws.com, port:6379} ]</code>. If none are set, a
* default address localhost:6379 will be used.
* {address: sample-address-0002.use2.cache.amazonaws.com, port:6379} ]</code>.
*/
@Singular private final List<NodeAddress> addresses;

Expand Down
11 changes: 2 additions & 9 deletions java/client/src/main/java/glide/managers/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,15 @@ private ConnectionRequest createConnectionRequest(BaseClientConfiguration config
private ConnectionRequest.Builder setupConnectionRequestBuilderBaseConfiguration(
BaseClientConfiguration configuration) {
ConnectionRequest.Builder connectionRequestBuilder = ConnectionRequest.newBuilder();
if (!configuration.getAddresses().isEmpty()) {
for (NodeAddress nodeAddress : configuration.getAddresses()) {
for (NodeAddress nodeAddress : configuration.getAddresses()) {
connectionRequestBuilder.addAddresses(
ConnectionRequestOuterClass.NodeAddress.newBuilder()
.setHost(nodeAddress.getHost())
.setPort(nodeAddress.getPort())
.build());
}
} else {
connectionRequestBuilder.addAddresses(
ConnectionRequestOuterClass.NodeAddress.newBuilder()
.setHost(DEFAULT_HOST)
.setPort(DEFAULT_PORT)
.build());
}


connectionRequestBuilder
.setTlsMode(configuration.isUseTLS() ? TlsMode.SecureTls : TlsMode.NoTls)
.setReadFrom(mapReadFromEnum(configuration.getReadFrom()));
Expand Down
3 changes: 1 addition & 2 deletions python/python/glide/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(
{address:sample-address-0001.use1.cache.amazonaws.com, port:6379},
{address: sample-address-0002.use2.cache.amazonaws.com, port:6379}
].
If none are set, a default address localhost:6379 will be used.
use_tls (bool): True if communication with the cluster should use Transport Level Security.
Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail
credentials (RedisCredentials): Credentials for authentication process.
Expand All @@ -126,7 +125,7 @@ def __init__(
If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not set, a default value will be used.
client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
"""
self.addresses = addresses or [NodeAddress()]
self.addresses = addresses
self.use_tls = use_tls
self.credentials = credentials
self.read_from = read_from
Expand Down

0 comments on commit a2da939

Please sign in to comment.