Skip to content

Better customization options for the underlying HTTP client #1024

Open
@nictas

Description

@nictas

We're using the CF Java client under a fairly high load (tens of thousands of requests per day) and we would like to enable the metrics feature of reactor-netty, so that we can see how many connections are used at any point in time:

return createHttpClient().compress(true) // Code taken from _DefaultConnectionContext.java
            .tcpConfiguration(this::configureTcpClient)
            .secure(this::configureSsl)
            .metrics(true, new CustomHttpClientMetricsRecorder());

This is currently not possible unless we also override the entire reactor-netty client via DefaultConnectionContext.builder().httpClient(...), which we don't want to do, because it would involve to copy-pasting the entire HttpClient building logic from _DefaultConnectionContext. I could make a pull request that allows users of the CF Java client to do:

DefaultConnectionContext.builder()
    .metrics(true) // OR
    .metrics(true, new CustomHttpClientMetricsRecorder())
    .build();

But I also don't particularly like that idea, because this doesn't cover any future features that the rector-netty devs may implement (or already have implemented). Maybe something like the following would be best?

DefaultConnectionContext.builder()
    .additionalHttpClientConfiguration(httpClient -> httpClient.metrics(true) // OR
        .metrics(true, new CustomHttpClientMetricsRecorder()))
    .build();

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement or new functionalityreactortriagedInitial triage of issue has been performed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions