Skip to content

Commit 006cda6

Browse files
authored
Adjust Rest5Client building by using and exposing the callbacks provided by the Elasticsearch Java client library.
Original Pull Request #3143 Closes #3129 Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
1 parent f51efa2 commit 006cda6

File tree

3 files changed

+380
-240
lines changed

3 files changed

+380
-240
lines changed

src/main/antora/modules/ROOT/pages/elasticsearch/clients.adoc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,63 @@ ClientConfiguration.builder()
389389
----
390390
====
391391

392+
[[elasticsearch.clients.configurationcallbacks.connectionconfig]]
393+
==== Configuration of the ConnectionConfig used by the low level Elasticsearch `Rest5Client`:
394+
395+
This callback provides a `org.apache.hc.client5.http.config.ConnectionConfig` to configure the connection that is
396+
used by the `Rest5Client`.
397+
398+
====
399+
[source,java]
400+
----
401+
ClientConfiguration.builder()
402+
.connectedTo("localhost:9200", "localhost:9291")
403+
.withClientConfigurer(Rest5Clients.ElasticsearchConnectionConfigurationCallback.from(connectionConfigBuilder -> {
404+
// configure the connection
405+
return connectionConfigBuilder;
406+
}))
407+
.build();
408+
----
409+
====
410+
411+
[[elasticsearch.clients.configurationcallbacks.connectioncmanager]]
412+
==== Configuration of the ConnectionManager used by the low level Elasticsearch `Rest5Client`:
413+
414+
This callback provides a `org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder` to configure the connection manager that is
415+
used by the `Rest5Client`.
416+
417+
====
418+
[source,java]
419+
----
420+
ClientConfiguration.builder()
421+
.connectedTo("localhost:9200", "localhost:9291")
422+
.withClientConfigurer(Rest5Clients.ElasticsearchConnectionManagerCallback.from(connectionManagerBuilder -> {
423+
// configure the connection manager
424+
return connectionManagerBuilder;
425+
}))
426+
.build();
427+
----
428+
====
429+
430+
[[elasticsearch.clients.configurationcallbacks.requestconfig]]
431+
==== Configuration of the RequestConfig used by the low level Elasticsearch `Rest5Client`:
432+
433+
This callback provides a `org.apache.hc.client5.http.config.RequestConfig` to configure the RequestConfig that is
434+
used by the `Rest5Client`.
435+
436+
====
437+
[source,java]
438+
----
439+
ClientConfiguration.builder()
440+
.connectedTo("localhost:9200", "localhost:9291")
441+
.withClientConfigurer(Rest5Clients.ElasticsearchRequestConfigCallback.from(requestConfigBuilder -> {
442+
// configure the request config
443+
return requestConfigBuilder;
444+
}))
445+
.build();
446+
----
447+
====
448+
392449
[[elasticsearch.clients.logging]]
393450
== Client Logging
394451

0 commit comments

Comments
 (0)