From 459d4ea40541312582cc8e754b84cea06b53f2bf Mon Sep 17 00:00:00 2001 From: Yingyu Cheng <1443504+winguse@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:28:47 -0700 Subject: [PATCH] document update regarding addressResolverGroup settings (#3007) * Update advanced-usage.md * update doc * update doc * pr comments (sorry for getting back late) * wrap with actual DnsAddressResolverGroup * use space --- docs/advanced-usage.md | 30 ++++++++++++++++++- .../core/resource/DefaultClientResources.java | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 23c3528de4..19e8c2b9d5 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -207,7 +207,7 @@ disabled by setting commandLatencyPublisherOptions(…) to DnsResolvers.JVM_DEFAULT ( or netty if present) -

Since: 3.5, 4.2

+

Since: 3.5, 4.2. Deprecated: 6.4

Configures a DNS resolver to resolve hostnames to a java.net.InetAddress. Defaults to the JVM DNS resolution that uses blocking hostname resolution and caching of lookup results. @@ -223,6 +223,34 @@ netty's AddressResolver that resolves DNS names on Bootstrap.connect() (requires netty 4.1)

+Address Resolver Group +addressResolverGroup +DefaultAddressResolverGroup.INSTANCE ( or netty DnsAddressResolverGroup if present) + + +

Since: 6.1

+

Sets the AddressResolverGroup for DNS resolution. This option is only effective if +DnsResolvers#UNRESOLVED is used as DnsResolver. Defaults to +io.netty.resolver.DefaultAddressResolverGroup#INSTANCE if netty-dns-resolver +is not available, otherwise defaults to io.netty.resolver.dns.DnsAddressResolverGroup

+

Users of DNS-based Redis-HA setups (e.g. AWS ElastiCache) might want to configure a different DNS +resolver group. For example: + +```java +new DnsAddressResolverGroup( + new DnsNameResolverBuilder(dnsEventLoop) + .channelType(NioDatagramChannel.class) + .resolveCache(NoopDnsCache.INSTANCE) + .cnameCache(NoopDnsCnameCache.INSTANCE) + .authoritativeDnsServerCache(NoopAuthoritativeDnsServerCache.INSTANCE) + .consolidateCacheSize(0) +); +``` + +

+ + + Reconnect Delay reconnectDelay Delay.exponential() diff --git a/src/main/java/io/lettuce/core/resource/DefaultClientResources.java b/src/main/java/io/lettuce/core/resource/DefaultClientResources.java index 592ffff4ab..a165978df6 100644 --- a/src/main/java/io/lettuce/core/resource/DefaultClientResources.java +++ b/src/main/java/io/lettuce/core/resource/DefaultClientResources.java @@ -442,7 +442,7 @@ public Builder computationThreadPoolSize(int computationThreadPoolSize) { /** * Sets the {@link DnsResolver} that is used to resolve hostnames to {@link java.net.InetAddress}. Defaults to - * {@link DnsResolvers#JVM_DEFAULT} + * {@link DnsResolvers#UNRESOLVED} * * @param dnsResolver the DNS resolver, must not be {@code null}. * @return {@code this} {@link Builder}.