Class AbstractEndpointSelector
java.lang.Object
com.linecorp.armeria.client.endpoint.AbstractEndpointSelector
- All Implemented Interfaces:
EndpointSelector
A skeletal
EndpointSelector
implementation. This abstract class implements the
select(ClientRequestContext, ScheduledExecutorService)
method by listening to
the change events emitted by EndpointGroup
specified at construction time.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractEndpointSelector
(EndpointGroup endpointGroup) Creates a new instance that selects anEndpoint
from the specifiedEndpointGroup
. -
Method Summary
Modifier and TypeMethodDescriptionprotected final EndpointGroup
group()
Returns theEndpointGroup
being selected by thisEndpointSelector
.protected final void
Initialize thisEndpointSelector
to listen to the new endpoints emitted by theEndpointGroup
.final CompletableFuture<Endpoint>
select
(ClientRequestContext ctx, ScheduledExecutorService executor) Selects anEndpoint
asynchronously from theEndpointGroup
associated with the specifiedClientRequestContext
, waiting up to the specifiedtimeoutMillis
.final CompletableFuture<Endpoint>
select
(ClientRequestContext ctx, ScheduledExecutorService executor, long timeoutMillis) Deprecated.protected void
updateNewEndpoints
(List<Endpoint> endpoints) Invoked when theEndpointGroup
has been updated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.endpoint.EndpointSelector
selectNow
-
Constructor Details
-
AbstractEndpointSelector
Creates a new instance that selects anEndpoint
from the specifiedEndpointGroup
.
-
-
Method Details
-
group
Returns theEndpointGroup
being selected by thisEndpointSelector
. -
select
@Deprecated public final CompletableFuture<Endpoint> select(ClientRequestContext ctx, ScheduledExecutorService executor, long timeoutMillis) Deprecated.Description copied from interface:EndpointSelector
Selects anEndpoint
asynchronously from theEndpointGroup
associated with the specifiedClientRequestContext
, waiting up to the specifiedtimeoutMillis
.- Specified by:
select
in interfaceEndpointSelector
- Parameters:
ctx
- theClientRequestContext
of theRequest
being handled.executor
- theScheduledExecutorService
used for notifying theCompletableFuture
being returned and scheduling timeout tasks.timeoutMillis
- the amount of milliseconds to wait until a successfulEndpoint
selection.- Returns:
- the
CompletableFuture
that will be completed with theEndpoint
selected by thisEndpointSelector
's selection strategy, or completed withnull
if noEndpoint
was selected within the specifiedtimeoutMillis
, which can happen if theEndpointGroup
is empty.
-
select
public final CompletableFuture<Endpoint> select(ClientRequestContext ctx, ScheduledExecutorService executor) Description copied from interface:EndpointSelector
Selects anEndpoint
asynchronously from theEndpointGroup
associated with the specifiedClientRequestContext
, waiting up to the specifiedtimeoutMillis
.- Specified by:
select
in interfaceEndpointSelector
- Parameters:
ctx
- theClientRequestContext
of theRequest
being handled.executor
- theScheduledExecutorService
used for notifying theCompletableFuture
being returned and scheduling timeout tasks.- Returns:
- the
CompletableFuture
that will be completed with theEndpoint
selected by thisEndpointSelector
's selection strategy, or completed withnull
if noEndpoint
was selected within the specifiedtimeoutMillis
, which can happen if theEndpointGroup
is empty.
-
initialize
Initialize thisEndpointSelector
to listen to the new endpoints emitted by theEndpointGroup
. The new endpoints will be passed toupdateNewEndpoints(List)
. -
updateNewEndpoints
Invoked when theEndpointGroup
has been updated.
-