use of com.linecorp.armeria.client.Endpoint in project curiostack by curioswitch.
the class ClientBuilderFactory method create.
public ClientBuilder create(String name, String url) {
URI uri = URI.create(url);
EndpointGroup endpoint = Endpoint.parse(uri.getAuthority());
if (((Endpoint) endpoint).authority().endsWith("cluster.local")) {
DnsAddressEndpointGroup dnsEndpointGroup = DnsAddressEndpointGroup.builder(uri.getHost()).port(uri.getPort()).ttl(1, 10).build();
dnsEndpointGroup.addListener(endpoints -> logger.info("Resolved new endpoints for {} : [ {} ]", name, endpoints.stream().map(e -> MoreObjects.firstNonNull(e.ipAddr(), e.authority())).collect(Collectors.joining(","))));
HealthCheckedEndpointGroup endpointGroup = HealthCheckedEndpointGroup.builder(dnsEndpointGroup, "/internal/health").clientFactory(clientFactory).protocol(SessionProtocol.HTTPS).retryInterval(Duration.ofSeconds(3)).build();
endpoint = endpointGroup;
}
ClientBuilder builder = Clients.builder(uri.getScheme(), endpoint, uri.getPath()).factory(clientFactory);
return builder.decorator(MetricCollectingClient.newDecorator(RpcMetricLabels.grpcRequestLabeler("grpc_clients"))).decorator(BraveClient.newDecorator(tracing)).decorator(loggingClient);
}
use of com.linecorp.armeria.client.Endpoint in project zipkin by openzipkin.
the class InitialEndpointSupplier method get.
@Override
public EndpointGroup get() {
List<EndpointGroup> endpointGroups = new ArrayList<>();
for (String hostText : hosts.split(",", 100)) {
// possibly extra comma
if ("".equals(hostText))
continue;
URI url;
if (hostText.startsWith("http://") || hostText.startsWith("https://")) {
url = URI.create(hostText);
} else if (!sessionProtocol.isTls() && hostText.indexOf(':') == -1) {
url = URI.create(sessionProtocol.uriText() + "://" + hostText + ":9200");
} else {
url = URI.create(sessionProtocol.uriText() + "://" + hostText);
}
String host = url.getHost();
if (host == null) {
LOGGER.warn("Skipping invalid ES host {}", url);
continue;
}
int port = getPort(url);
if (port == 9300) {
LOGGER.warn("Native transport no longer supported. Changing {} to http port 9200", host);
port = 9200;
}
if (isIpAddress(host) || host.equals("localhost")) {
endpointGroups.add(EndpointGroup.of(Endpoint.of(host, port)));
} else {
// A host that isn't an IP may resolve to multiple IP addresses, so we use a endpoint
// group to round-robin over them. Users can mix addresses that resolve to multiple IPs
// with single IPs freely, they'll all get used.
endpointGroups.add(DnsAddressEndpointGroup.builder(host).port(port).build());
}
}
if (endpointGroups.isEmpty()) {
throw new IllegalArgumentException("No valid endpoints found in ES hosts: " + hosts);
}
return EndpointGroup.of(endpointGroups);
}
Aggregations