use of com.linecorp.armeria.client.ClientFactory 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);
}
Aggregations