Class CentralDogmaEndpointGroup<T>
java.lang.Object
com.linecorp.armeria.common.util.AbstractListenable<List<Endpoint>>
com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
com.linecorp.centraldogma.client.armeria.CentralDogmaEndpointGroup<T>
- Type Parameters:
T
- the type of the file in Central Dogma
- All Implemented Interfaces:
EndpointGroup
,EndpointSelector
,AsyncCloseable
,Listenable<List<Endpoint>>
,ListenableAsyncCloseable
,AutoCloseable
A
DynamicEndpointGroup
implementation that retrieves the Endpoint
list from an entry in
Central Dogma. The entry can be a JSON file or a plain text file.
For example, the following JSON array will be served as a list of Endpoint
s:
[
"host1:port1",
"host2:port2",
"host3:port3"
]
The JSON array file could be retrieved as an EndpointGroup
using the following code:
CentralDogmaEndpointGroup<JsonNode> endpointGroup = CentralDogmaEndpointGroup.of(
centralDogma, "myProject", "myRepo",
Query.ofJson("/endpoints.json"),
EndpointListDecoder.JSON);
endpointGroup.awaitInitialEndpoints();
endpointGroup.endpoints();
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CentralDogmaEndpointGroupBuilder
<T> builder
(Watcher<T> watcher, EndpointListDecoder<T> endpointListDecoder) protected void
doCloseAsync
(CompletableFuture<?> future) static <T> CentralDogmaEndpointGroup
<T> of
(CentralDogma centralDogma, String projectName, String repositoryName, Query<T> query, EndpointListDecoder<T> endpointListDecoder) Creates a newCentralDogmaEndpointGroup
.static <T> CentralDogmaEndpointGroup
<T> ofWatcher
(Watcher<T> watcher, EndpointListDecoder<T> endpointListDecoder) Creates a newCentralDogmaEndpointGroup
.toString()
Methods inherited from class com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
addEndpoint, allowsEmptyEndpoints, builder, close, closeAsync, endpoints, isClosed, isClosing, latestValue, removeEndpoint, select, select, selectionStrategy, selectionTimeoutMillis, selectNow, setEndpoints, toString, toStringSelector, 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
-
ofWatcher
public static <T> CentralDogmaEndpointGroup<T> ofWatcher(Watcher<T> watcher, EndpointListDecoder<T> endpointListDecoder) Creates a newCentralDogmaEndpointGroup
.- Parameters:
watcher
- aWatcher
endpointListDecoder
- anEndpointListDecoder
-
of
public static <T> CentralDogmaEndpointGroup<T> of(CentralDogma centralDogma, String projectName, String repositoryName, Query<T> query, EndpointListDecoder<T> endpointListDecoder) Creates a newCentralDogmaEndpointGroup
.- Parameters:
centralDogma
- aCentralDogma
projectName
- a Central Dogma project namerepositoryName
- a Central Dogma repository namequery
- aQuery
to route fileendpointListDecoder
- anEndpointListDecoder
-
builder
public static <T> CentralDogmaEndpointGroupBuilder<T> builder(Watcher<T> watcher, EndpointListDecoder<T> endpointListDecoder) Returns a newCentralDogmaEndpointGroupBuilder
with theWatcher
andEndpointListDecoder
. You can create aWatcher
usingCentralDogma
:CentralDogma centralDogma = ... Query<T> query = ... // The query to the entry that contains the list of endpoints. Watcher watcher = centralDogma.fileWatcher(projectName, repositoryName, query);
-
doCloseAsync
- Overrides:
doCloseAsync
in classDynamicEndpointGroup
-
toString
- Overrides:
toString
in classDynamicEndpointGroup
-