Class AbstractEndpointSelector
java.lang.Object
com.linecorp.armeria.client.endpoint.AbstractEndpointSelector
- All Implemented Interfaces:
EndpointSelector
public abstract class AbstractEndpointSelector extends Object implements EndpointSelector
A skeletal
EndpointSelector
implementation. This abstract class implements the
select(ClientRequestContext, ScheduledExecutorService, long)
method by listening to
the change events emitted by EndpointGroup
specified at construction time.-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEndpointSelector(EndpointGroup endpointGroup)
Creates a new instance that selects anEndpoint
from the specifiedEndpointGroup
. -
Method Summary
Modifier and Type Method Description protected EndpointGroup
group()
Returns theEndpointGroup
being selected by thisEndpointSelector
.CompletableFuture<Endpoint>
select(ClientRequestContext ctx, ScheduledExecutorService executor, long timeoutMillis)
Selects anEndpoint
asynchronously from theEndpointGroup
associated with the specifiedClientRequestContext
, waiting up to the specifiedtimeoutMillis
.
-
Constructor Details
-
AbstractEndpointSelector
Creates a new instance that selects anEndpoint
from the specifiedEndpointGroup
.
-
-
Method Details
-
group
Returns theEndpointGroup
being selected by thisEndpointSelector
. -
select
public final CompletableFuture<Endpoint> select(ClientRequestContext ctx, ScheduledExecutorService executor, long timeoutMillis)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.
-