Interface EndpointGroup
- All Superinterfaces:
AsyncCloseable
,AutoCloseable
,EndpointSelector
,Listenable<List<Endpoint>>
- All Known Implementing Classes:
DnsAddressEndpointGroup
,DnsServiceEndpointGroup
,DnsTextEndpointGroup
,DynamicEndpointGroup
,Endpoint
,HealthCheckedEndpointGroup
,PropertiesEndpointGroup
,ZooKeeperEndpointGroup
public interface EndpointGroup extends Listenable<List<Endpoint>>, EndpointSelector, AsyncCloseable
A list of
Endpoint
s.-
Method Summary
Modifier and Type Method Description default void
addListener(Consumer<? super List<Endpoint>> listener)
Adds aConsumer
that will be invoked when aListenable
changes its value.static EndpointGroup
empty()
Returns a singletonEndpointGroup
which does not contain anyEndpoint
s.List<Endpoint>
endpoints()
Returns the endpoints held by thisEndpointGroup
.static EndpointGroup
of(EndpointGroup... endpointGroups)
static EndpointGroup
of(EndpointSelectionStrategy selectionStrategy, EndpointGroup... endpointGroups)
static EndpointGroup
of(EndpointSelectionStrategy selectionStrategy, Iterable<? extends EndpointGroup> endpointGroups)
static EndpointGroup
of(Iterable<? extends EndpointGroup> endpointGroups)
default EndpointGroup
orElse(EndpointGroup nextEndpointGroup)
Creates a newEndpointGroup
that tries thisEndpointGroup
first and then the specifiedEndpointGroup
when thisEndpointGroup
does not have a requested resource.default void
removeListener(Consumer<?> listener)
Remove a listener.Endpoint
select(ClientRequestContext ctx)
Selects anEndpoint
from thisEndpointGroup
.EndpointSelectionStrategy
selectionStrategy()
Returns theEndpointSelectionStrategy
of thisEndpointGroup
.CompletableFuture<List<Endpoint>>
whenReady()
Returns aCompletableFuture
which is completed when the initialEndpoint
s are ready.
-
Method Details
-
empty
Returns a singletonEndpointGroup
which does not contain anyEndpoint
s. -
of
Returns anEndpointGroup
that combines all theEndpoint
s ofendpointGroups
.endpointGroups
can be instances ofEndpoint
as well, anyEndpointGroup
s andEndpoint
will all be combined into a singleEndpointGroup
that contains the total set. TheEndpointGroup
returned by this method will useEndpointSelectionStrategy.weightedRoundRobin()
for selecting anEndpoint
. -
of
static EndpointGroup of(EndpointSelectionStrategy selectionStrategy, EndpointGroup... endpointGroups)Returns anEndpointGroup
that combines all theEndpoint
s ofendpointGroups
.endpointGroups
can be instances ofEndpoint
as well, anyEndpointGroup
s andEndpoint
will all be combined into a singleEndpointGroup
that contains the total set. -
of
Returns anEndpointGroup
that combines all theEndpoint
s ofendpointGroups
.endpointGroups
can be instances ofEndpoint
as well, anyEndpointGroup
s andEndpoint
will all be combined into a singleEndpointGroup
that contains the total set. TheEndpointGroup
returned by this method will useEndpointSelectionStrategy.weightedRoundRobin()
for selecting anEndpoint
. -
of
static EndpointGroup of(EndpointSelectionStrategy selectionStrategy, Iterable<? extends EndpointGroup> endpointGroups)Returns anEndpointGroup
that combines all theEndpoint
s ofendpointGroups
.endpointGroups
can be instances ofEndpoint
as well, anyEndpointGroup
s andEndpoint
will all be combined into a singleEndpointGroup
that contains the total set. -
endpoints
Returns the endpoints held by thisEndpointGroup
. -
selectionStrategy
EndpointSelectionStrategy selectionStrategy()Returns theEndpointSelectionStrategy
of thisEndpointGroup
. -
select
Selects anEndpoint
from thisEndpointGroup
.- Specified by:
select
in interfaceEndpointSelector
- Returns:
- the
Endpoint
selected by theEndpointSelectionStrategy
, which was specified when constructing thisEndpointGroup
.
-
whenReady
CompletableFuture<List<Endpoint>> whenReady()Returns aCompletableFuture
which is completed when the initialEndpoint
s are ready. -
addListener
Description copied from interface:Listenable
Adds aConsumer
that will be invoked when aListenable
changes its value.- Specified by:
addListener
in interfaceListenable<List<Endpoint>>
-
removeListener
Description copied from interface:Listenable
Remove a listener.- Specified by:
removeListener
in interfaceListenable<List<Endpoint>>
-
orElse
Creates a newEndpointGroup
that tries thisEndpointGroup
first and then the specifiedEndpointGroup
when thisEndpointGroup
does not have a requested resource.- Parameters:
nextEndpointGroup
- theEndpointGroup
to try secondly.
-