use of com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup 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.healthcheck.HealthCheckedEndpointGroup in project zipkin by openzipkin.
the class LazyHttpClientImpl method decorateHealthCheck.
// Enables health-checking of an endpoint group, so we only send requests to endpoints that are up
HealthCheckedEndpointGroup decorateHealthCheck(EndpointGroup endpointGroup) {
HealthCheckedEndpointGroup healthChecked = HealthCheckedEndpointGroup.builder(endpointGroup, "/_cluster/health").protocol(protocol).useGet(true).clientFactory(factory.clientFactory).withClientOptions(options -> {
factory.configureHttpLogging(healthCheck.getHttpLogging(), options);
factory.configureOptionsExceptHttpLogging(options);
options.decorator(MetricCollectingClient.newDecorator(MeterIdPrefixFunction.ofDefault("elasticsearch-healthcheck")));
options.decorator((delegate, ctx, req) -> {
ctx.logBuilder().name("health-check");
return delegate.execute(ctx, req);
});
return options;
}).retryInterval(healthCheck.getInterval()).build();
healthChecked.newMeterBinder("elasticsearch").bindTo(meterRegistry);
return healthChecked;
}
Aggregations