Class DefaultDnsServiceDiscovererBuilder
- java.lang.Object
-
- io.servicetalk.dns.discovery.netty.DefaultDnsServiceDiscovererBuilder
-
public final class DefaultDnsServiceDiscovererBuilder extends java.lang.Object
Builder for DNSServiceDiscoverer
which will attempt to resolveA
,AAAA
,CNAME
, andSRV
type queries.
-
-
Constructor Summary
Constructors Constructor Description DefaultDnsServiceDiscovererBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>>
buildARecordDiscoverer()
Build a newServiceDiscoverer
which targets host addresses (e.g.ServiceDiscoverer<java.lang.String,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>>
buildSrvDiscoverer()
DefaultDnsServiceDiscovererBuilder
dnsResolverAddressTypes(DnsResolverAddressTypes dnsResolverAddressTypes)
Sets the list of the protocol families of the address resolved.DefaultDnsServiceDiscovererBuilder
dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
Set theDnsServerAddressStreamProvider
which determines which DNS server should be used per query.DefaultDnsServiceDiscovererBuilder
ioExecutor(IoExecutor ioExecutor)
Sets theIoExecutor
.DefaultDnsServiceDiscovererBuilder
maxUdpPayloadSize(int maxUdpPayloadSize)
Set the maximum size of the receiving UDP datagram (in bytes).DefaultDnsServiceDiscovererBuilder
minTTL(int minTTLSeconds)
The minimum allowed TTL.DefaultDnsServiceDiscovererBuilder
ndots(int ndots)
Set the number of dots which must appear in a name before an initial absolute query is made.DefaultDnsServiceDiscovererBuilder
observer(DnsServiceDiscovererObserver observer)
Sets aDnsServiceDiscovererObserver
that provides visibility into DNSServiceDiscoverer
built by this builder.DefaultDnsServiceDiscovererBuilder
optResourceEnabled(boolean optResourceEnabled)
Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response.DefaultDnsServiceDiscovererBuilder
queryTimeout(java.time.Duration queryTimeout)
Sets the timeout of each DNS query performed by this service discoverer.
-
-
-
Method Detail
-
minTTL
public DefaultDnsServiceDiscovererBuilder minTTL(int minTTLSeconds)
The minimum allowed TTL. This will be the minimum poll interval.- Parameters:
minTTLSeconds
- The minimum amount of time a cache entry will be considered valid (in seconds).- Returns:
this
.
-
dnsServerAddressStreamProvider
public DefaultDnsServiceDiscovererBuilder dnsServerAddressStreamProvider(@Nullable DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
Set theDnsServerAddressStreamProvider
which determines which DNS server should be used per query.- Parameters:
dnsServerAddressStreamProvider
- theDnsServerAddressStreamProvider
which determines which DNS server should be used per query.- Returns:
this
.
-
optResourceEnabled
public DefaultDnsServiceDiscovererBuilder optResourceEnabled(boolean optResourceEnabled)
Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response. Some DNSServer may not support this and so fail to answer queries. If you find problems you may want to disable this.- Parameters:
optResourceEnabled
- if optional records inclusion is enabled.- Returns:
this
.
-
maxUdpPayloadSize
public DefaultDnsServiceDiscovererBuilder maxUdpPayloadSize(int maxUdpPayloadSize)
Set the maximum size of the receiving UDP datagram (in bytes).If the DNS response exceeds this amount the request will be automatically retried via TCP.
- Parameters:
maxUdpPayloadSize
- the maximum size of the receiving UDP datagram (in bytes)- Returns:
this
.
-
ndots
public DefaultDnsServiceDiscovererBuilder ndots(int ndots)
Set the number of dots which must appear in a name before an initial absolute query is made.- Parameters:
ndots
- the ndots value.- Returns:
this
.
-
queryTimeout
public DefaultDnsServiceDiscovererBuilder queryTimeout(java.time.Duration queryTimeout)
Sets the timeout of each DNS query performed by this service discoverer.- Parameters:
queryTimeout
- the query timeout value- Returns:
this
.
-
dnsResolverAddressTypes
public DefaultDnsServiceDiscovererBuilder dnsResolverAddressTypes(@Nullable DnsResolverAddressTypes dnsResolverAddressTypes)
Sets the list of the protocol families of the address resolved.- Parameters:
dnsResolverAddressTypes
- the address types.- Returns:
this
.
-
ioExecutor
public DefaultDnsServiceDiscovererBuilder ioExecutor(IoExecutor ioExecutor)
Sets theIoExecutor
.- Parameters:
ioExecutor
-IoExecutor
to use.- Returns:
this
.
-
observer
public DefaultDnsServiceDiscovererBuilder observer(DnsServiceDiscovererObserver observer)
Sets aDnsServiceDiscovererObserver
that provides visibility into DNSServiceDiscoverer
built by this builder.- Parameters:
observer
- aDnsServiceDiscovererObserver
that provides visibility into DNSServiceDiscoverer
built by this builder- Returns:
this
.
-
buildSrvDiscoverer
public ServiceDiscoverer<java.lang.String,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> buildSrvDiscoverer()
Build a newServiceDiscoverer
which queries SRV Resource Records corresponding toserviceName
. For each SRV answer capture the Port and resolve the Target.- Returns:
- a new
ServiceDiscoverer
which queries SRV Resource Records corresponding toserviceName
. For each SRV answer capture the Port and resolve the Target.
-
buildARecordDiscoverer
public ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> buildARecordDiscoverer()
Build a newServiceDiscoverer
which targets host addresses (e.g. A or AAAA records) and uses a fixed port derived from theHostAndPort
.- Returns:
- a new
ServiceDiscoverer
which targets host addresses (e.g. A or AAAA records) and uses a fixed port derived from theHostAndPort
.
-
-