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 newDnsServiceEndpointGroupBuilderwith the specified hostname.protected final voiddoCloseAsync(CompletableFuture<?> future) Stops polling DNS servers for service updates.static DnsServiceEndpointGroupCreates aDnsServiceEndpointGroupthat schedules queries on a randomEventLoopfromCommonPools.workerGroup().voidonEviction(DnsQuestion question, @Nullable List<DnsRecord> records, @Nullable UnknownHostException cause) Invoked when an eviction occurred for theDnsRecords.final voidonRemoval(DnsQuestion question, @Nullable List<DnsRecord> records, @Nullable UnknownHostException cause) Invoked when theDnsRecords 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, toStringSelector, whenClosed, whenReadyMethods inherited from class com.linecorp.armeria.common.util.AbstractListenable
addListener, addListener, notifyListeners, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.linecorp.armeria.client.endpoint.EndpointGroup
addListener, addListener, orElse, removeListener
-
Method Details
-
of
Creates aDnsServiceEndpointGroupthat schedules queries on a randomEventLoopfromCommonPools.workerGroup().- Parameters:
hostname- the hostname to query DNS queries for.
-
builder
Returns a newDnsServiceEndpointGroupBuilderwith 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:DnsCacheListenerInvoked when theDnsRecords expired due to TTL or negative TTL.- Specified by:
onRemovalin interfaceDnsCacheListener- Parameters:
question- the DNS question.records- the result of a successful DNS resolution.nullif failed.cause- the cause of a failed DNS resolution.nullif succeeded.
-
onEviction
public void onEviction(DnsQuestion question, @Nullable @Nullable List<DnsRecord> records, @Nullable @Nullable UnknownHostException cause) Description copied from interface:DnsCacheListenerInvoked when an eviction occurred for theDnsRecords. The eviction occurs due to exceeding the maximum size.- Specified by:
onEvictionin interfaceDnsCacheListener- Parameters:
question- the DNS question.records- the result of a successful DNS resolution.nullif failed.cause- the cause of a failed DNS resolution.nullif succeeded.
-
doCloseAsync
Stops polling DNS servers for service updates.- Overrides:
doCloseAsyncin classDynamicEndpointGroup
-
toString
- Overrides:
toStringin classDynamicEndpointGroup
-