Class DnsServiceEndpointGroup
java.lang.Object
com.linecorp.armeria.common.util.AbstractListenable<List<Endpoint>>
com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
com.linecorp.armeria.client.endpoint.dns.DnsServiceEndpointGroup
- All Implemented Interfaces:
DnsCacheListener
,EndpointGroup
,EndpointSelector
,AsyncCloseable
,Listenable<List<Endpoint>>
,ListenableAsyncCloseable
,AutoCloseable
DynamicEndpointGroup
which resolves targets using DNS
SRV records. This is useful for environments
where service discovery is handled using DNS, e.g.
Kubernetes DNS-based service
discovery.-
Method Summary
Modifier and TypeMethodDescriptionReturns a newDnsServiceEndpointGroupBuilder
with the specified hostname.protected final void
doCloseAsync
(CompletableFuture<?> future) Stops polling DNS servers for service updates.static DnsServiceEndpointGroup
Creates aDnsServiceEndpointGroup
that schedules queries on a randomEventLoop
fromCommonPools.workerGroup()
.void
onEviction
(DnsQuestion question, @Nullable List<DnsRecord> records, @Nullable UnknownHostException cause) Invoked when an eviction occurred for theDnsRecord
s.final void
onRemoval
(DnsQuestion question, @Nullable List<DnsRecord> records, @Nullable UnknownHostException cause) Invoked when theDnsRecord
s expired due to TTL or negative TTL.toString()
Methods inherited from class com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
addEndpoint, allowsEmptyEndpoints, builder, close, closeAsync, endpoints, isClosed, isClosing, latestValue, removeEndpoint, select, select, selectionStrategy, selectionTimeoutMillis, selectNow, setEndpoints, toString, whenClosed, whenReady
Methods inherited from class com.linecorp.armeria.common.util.AbstractListenable
addListener, addListener, notifyListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.endpoint.EndpointGroup
addListener, addListener, orElse, removeListener
-
Method Details
-
of
Creates aDnsServiceEndpointGroup
that schedules queries on a randomEventLoop
fromCommonPools.workerGroup()
.- Parameters:
hostname
- the hostname to query DNS queries for.
-
builder
Returns a newDnsServiceEndpointGroupBuilder
with the specified hostname.- Parameters:
hostname
- the hostname to query DNS queries for
-
onRemoval
public final void onRemoval(DnsQuestion question, @Nullable @Nullable List<DnsRecord> records, @Nullable @Nullable UnknownHostException cause) Description copied from interface:DnsCacheListener
Invoked when theDnsRecord
s expired due to TTL or negative TTL.- Specified by:
onRemoval
in interfaceDnsCacheListener
- Parameters:
question
- the DNS question.records
- the result of a successful DNS resolution.null
if failed.cause
- the cause of a failed DNS resolution.null
if succeeded.
-
onEviction
public void onEviction(DnsQuestion question, @Nullable @Nullable List<DnsRecord> records, @Nullable @Nullable UnknownHostException cause) Description copied from interface:DnsCacheListener
Invoked when an eviction occurred for theDnsRecord
s. The eviction occurs due to exceeding the maximum size.- Specified by:
onEviction
in interfaceDnsCacheListener
- Parameters:
question
- the DNS question.records
- the result of a successful DNS resolution.null
if failed.cause
- the cause of a failed DNS resolution.null
if succeeded.
-
doCloseAsync
Stops polling DNS servers for service updates.- Overrides:
doCloseAsync
in classDynamicEndpointGroup
-
toString
- Overrides:
toString
in classDynamicEndpointGroup
-