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 Endpoints 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 createdHealthCheckedEndpointGroupBuilderthat builds aHealthCheckedEndpointGroupwhich sends HTTPHEADhealth check requests.protected voiddoCloseAsync(CompletableFuture<?> future) Override this method to release the resources held by thisEndpointGroupand complete the specifiedCompletableFuture.newMeterBinder(MeterIdPrefix idPrefix) Returns a newly-createdMeterBinderwhich binds the stats about thisHealthCheckedEndpointGroup.newMeterBinder(String groupName) Returns a newly-createdMeterBinderwhich binds the stats about thisHealthCheckedEndpointGroupwith the default meter names.static HealthCheckedEndpointGroupof(EndpointGroup delegate, String path) Returns a newly createdHealthCheckedEndpointGroupthat sends HTTPHEADhealth check requests with default options.longReturns the timeout to wait until a successfulEndpointselection.toString()Methods inherited from class com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
addEndpoint, allowsEmptyEndpoints, builder, close, closeAsync, endpoints, isClosed, isClosing, latestValue, removeEndpoint, select, select, selectionStrategy, 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
Returns a newly createdHealthCheckedEndpointGroupthat sends HTTPHEADhealth check requests with default options.- Parameters:
delegate- theEndpointGroupthat provides the candidateEndpointspath- the HTTP request path, e.g."/internal/l7check"
-
builder
Returns a newly createdHealthCheckedEndpointGroupBuilderthat builds aHealthCheckedEndpointGroupwhich sends HTTPHEADhealth check requests.- Parameters:
delegate- theEndpointGroupthat provides the candidateEndpointspath- the HTTP request path, e.g."/internal/l7check"
-
selectionTimeoutMillis
public long selectionTimeoutMillis()Description copied from interface:EndpointGroupReturns the timeout to wait until a successfulEndpointselection. If anEndpointis not resolved by thisEndpointGroupwithin the timeout, a null value will be returned byEndpointSelector.select(ClientRequestContext, ScheduledExecutorService). The nullEndpointmay cause a client request end with anEndpointSelectionTimeoutExceptionif noRetryingClientis configured.0meansEndpointGroup.selectNow(ClientRequestContext)should always return anEndpoint.- Specified by:
selectionTimeoutMillisin interfaceEndpointGroup- Overrides:
selectionTimeoutMillisin classDynamicEndpointGroup
-
doCloseAsync
Description copied from class:DynamicEndpointGroupOverride this method to release the resources held by thisEndpointGroupand complete the specifiedCompletableFuture.- Overrides:
doCloseAsyncin classDynamicEndpointGroup
-
newMeterBinder
Returns a newly-createdMeterBinderwhich binds the stats about thisHealthCheckedEndpointGroupwith the default meter names. -
newMeterBinder
Returns a newly-createdMeterBinderwhich binds the stats about thisHealthCheckedEndpointGroup. -
toString
- Overrides:
toStringin classDynamicEndpointGroup
-