helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.5k stars 566 forks source link

Add example/doc about configuration of HelidonConnector #6728

Open arjav-desai opened 1 year ago

arjav-desai commented 1 year ago

Currently, we don't have doc/example about setting/configuring HelidonConnector.

When we look at https://github.com/helidon-io/helidon/blob/helidon-3.x/jersey/connector/src/main/java/io/helidon/jersey/connector/HelidonConnector.java, the connector has options for configuring followRedirects and readTimeout, but nothing to control keepAlive. HelidonConnector is based-on/used WebClient underneath which supports keepAliveWebClient but I don't see a way to turn that on through the connector.

spericas commented 1 year ago

Had a chance to explore this a bit more. There seems to be a way to configure the connector now, using a Config object and a special property. This should work to set any property on the underlying WebClient used by the HelidonConnector, including the keep alive setting. Here is sample code that shows how to do it:

Config config = Config.builder()
                .addSource(MapConfigSource.create(Collections.singletonMap("keep-alive", "true")))
                .build();
Client client = ClientBuilder.newBuilder()
                .property("jersey.connector.helidon.config", config)
                .build();

The config object will be used to configure the underlying WebClient created by the connector.

spericas commented 1 year ago

Created #7640 for 4.x (PR #7641). Re-targeting this to 3.x.