Search in sources :

Example 1 with LoggingClient

use of com.linecorp.armeria.client.logging.LoggingClient 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);
}
Also used : HealthCheckedEndpointGroup(com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup) SessionProtocol(com.linecorp.armeria.common.SessionProtocol) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) ResourceUtil(org.curioswitch.common.server.framework.util.ResourceUtil) BraveClient(com.linecorp.armeria.client.brave.BraveClient) Singleton(javax.inject.Singleton) Function(java.util.function.Function) Inject(javax.inject.Inject) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) EventLoopGroups(com.linecorp.armeria.common.util.EventLoopGroups) RpcMetricLabels(org.curioswitch.common.server.framework.monitoring.RpcMetricLabels) Duration(java.time.Duration) Clients(com.linecorp.armeria.client.Clients) ClientBuilder(com.linecorp.armeria.client.ClientBuilder) URI(java.net.URI) ClientFactoryBuilder(com.linecorp.armeria.client.ClientFactoryBuilder) Tracing(brave.Tracing) DnsAddressEndpointGroup(com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup) ClientFactory(com.linecorp.armeria.client.ClientFactory) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) MetricCollectingClient(com.linecorp.armeria.client.metric.MetricCollectingClient) MoreObjects(com.google.common.base.MoreObjects) EndpointGroup(com.linecorp.armeria.client.endpoint.EndpointGroup) Endpoint(com.linecorp.armeria.client.Endpoint) DnsServerAddressStreamProviders(io.netty.resolver.dns.DnsServerAddressStreamProviders) Collectors(java.util.stream.Collectors) LoggingClient(com.linecorp.armeria.client.logging.LoggingClient) Consumer(java.util.function.Consumer) Logger(org.apache.logging.log4j.Logger) ServerConfig(org.curioswitch.common.server.framework.config.ServerConfig) HttpClient(com.linecorp.armeria.client.HttpClient) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) Optional(java.util.Optional) DnsAddressResolverGroup(io.netty.resolver.dns.DnsAddressResolverGroup) LogManager(org.apache.logging.log4j.LogManager) HealthCheckedEndpointGroup(com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup) HealthCheckedEndpointGroup(com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup) DnsAddressEndpointGroup(com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup) EndpointGroup(com.linecorp.armeria.client.endpoint.EndpointGroup) URI(java.net.URI) DnsAddressEndpointGroup(com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup) ClientBuilder(com.linecorp.armeria.client.ClientBuilder)

Aggregations

Tracing (brave.Tracing)1 MoreObjects (com.google.common.base.MoreObjects)1 ClientBuilder (com.linecorp.armeria.client.ClientBuilder)1 ClientFactory (com.linecorp.armeria.client.ClientFactory)1 ClientFactoryBuilder (com.linecorp.armeria.client.ClientFactoryBuilder)1 Clients (com.linecorp.armeria.client.Clients)1 Endpoint (com.linecorp.armeria.client.Endpoint)1 HttpClient (com.linecorp.armeria.client.HttpClient)1 BraveClient (com.linecorp.armeria.client.brave.BraveClient)1 EndpointGroup (com.linecorp.armeria.client.endpoint.EndpointGroup)1 DnsAddressEndpointGroup (com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup)1 HealthCheckedEndpointGroup (com.linecorp.armeria.client.endpoint.healthcheck.HealthCheckedEndpointGroup)1 LoggingClient (com.linecorp.armeria.client.logging.LoggingClient)1 MetricCollectingClient (com.linecorp.armeria.client.metric.MetricCollectingClient)1 SessionProtocol (com.linecorp.armeria.common.SessionProtocol)1 EventLoopGroups (com.linecorp.armeria.common.util.EventLoopGroups)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)1 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)1 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)1