Better customization options for the underlying HTTP client

Open
#1,024 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
api, backend

Research direction

Read _DefaultConnectionContext and the DefaultConnectionContext.builder entry point to understand how the reactor-netty HttpClient is assembled. Compare the proposed metrics options with the additionalHttpClientConfiguration hook, then identify existing client-building tests; done means callers can customize the underlying client without replacing the complete construction logic.

Written by the indexing model from the issue text.

Description

enhancement reactor triaged

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?

Dominant language
Java
Stars
334
Forks
319
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudfoundry/cf-java-client

All issues in cloudfoundry/cf-java-client

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.