Class HealthCheckedEndpointGroup
java.lang.Object
com.linecorp.armeria.common.util.AbstractListenable<List<Endpoint>>
com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup
- All Implemented Interfaces:
EndpointGroup
,EndpointSelector
,AsyncCloseable
,Listenable<List<Endpoint>>
,ListenableAsyncCloseable
,AutoCloseable
An
EndpointGroup
that filters out unhealthy Endpoint
s from an existing EndpointGroup
,
by sending periodic health check requests.
EndpointGroup originalGroup = ...
// Decorate the EndpointGroup with HealthCheckedEndpointGroup
// that sends HTTP health check requests to '/internal/l7check' every 10 seconds.
HealthCheckedEndpointGroup healthCheckedGroup =
HealthCheckedEndpointGroup.builder(originalGroup, "/internal/l7check")
.protocol(SessionProtocol.HTTP)
.retryInterval(Duration.ofSeconds(10))
.build();
// You must specify healthCheckedGroup when building a WebClient, otherwise health checking
// will not be enabled.
WebClient client = WebClient.builder(SessionProtocol.HTTP, healthCheckedGroup)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(EndpointGroup delegate, String path) Returns a newly createdHealthCheckedEndpointGroupBuilder
that builds aHealthCheckedEndpointGroup
which sends HTTPHEAD
health check requests.protected void
doCloseAsync
(CompletableFuture<?> future) Override this method to release the resources held by thisEndpointGroup
and complete the specifiedCompletableFuture
.Returns the latest value notified before.newMeterBinder
(MeterIdPrefix idPrefix) Returns a newly-createdMeterBinder
which binds the stats about thisHealthCheckedEndpointGroup
.newMeterBinder
(String groupName) Returns a newly-createdMeterBinder
which binds the stats about thisHealthCheckedEndpointGroup
with the default meter names.static HealthCheckedEndpointGroup
of
(EndpointGroup delegate, String path) Returns a newly createdHealthCheckedEndpointGroup
that sends HTTPHEAD
health check requests with default options.long
Returns the timeout to wait until a successfulEndpoint
selection.toString()
Methods inherited from class com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
addEndpoint, allowsEmptyEndpoints, builder, close, closeAsync, endpoints, isClosed, isClosing, removeEndpoint, select, select, selectionStrategy, selectNow, setEndpoints, toStringHelper, 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
Returns a newly createdHealthCheckedEndpointGroup
that sends HTTPHEAD
health check requests with default options.- Parameters:
delegate
- theEndpointGroup
that provides the candidateEndpoint
spath
- the HTTP request path, e.g."/internal/l7check"
-
builder
Returns a newly createdHealthCheckedEndpointGroupBuilder
that builds aHealthCheckedEndpointGroup
which sends HTTPHEAD
health check requests.- Parameters:
delegate
- theEndpointGroup
that provides the candidateEndpoint
spath
- the HTTP request path, e.g."/internal/l7check"
-
selectionTimeoutMillis
public long selectionTimeoutMillis()Description copied from interface:EndpointGroup
Returns the timeout to wait until a successfulEndpoint
selection. If anEndpoint
is not resolved by thisEndpointGroup
within the timeout, a null value will be returned byEndpointSelector.select(ClientRequestContext, ScheduledExecutorService)
. The nullEndpoint
may cause a client request end with anEndpointSelectionTimeoutException
if noRetryingClient
is configured.0
meansEndpointGroup.selectNow(ClientRequestContext)
should always return anEndpoint
.- Specified by:
selectionTimeoutMillis
in interfaceEndpointGroup
- Overrides:
selectionTimeoutMillis
in classDynamicEndpointGroup
-
doCloseAsync
Description copied from class:DynamicEndpointGroup
Override this method to release the resources held by thisEndpointGroup
and complete the specifiedCompletableFuture
.- Overrides:
doCloseAsync
in classDynamicEndpointGroup
-
newMeterBinder
Returns a newly-createdMeterBinder
which binds the stats about thisHealthCheckedEndpointGroup
with the default meter names. -
newMeterBinder
Returns a newly-createdMeterBinder
which binds the stats about thisHealthCheckedEndpointGroup
. -
toString
- Overrides:
toString
in classDynamicEndpointGroup
-
latestValue
Description copied from class:AbstractListenable
Returns the latest value notified before.null
if the value has not been initialized yet or the implementation of this class cannot cache it.- Overrides:
latestValue
in classAbstractListenable<List<Endpoint>>
-