|
62 | 62 | @SuppressWarnings("unused")
|
63 | 63 | public final class OpenSearchClients {
|
64 | 64 | public static final String IMPERATIVE_CLIENT = "imperative";
|
| 65 | + public static final String REACTIVE_CLIENT = "reactive"; |
65 | 66 |
|
66 | 67 | /**
|
67 | 68 | * Name of whose value can be used to correlate log messages for this request.
|
@@ -282,6 +283,93 @@ public static OpenSearchTransport getOpenSearchTransport(RestClient restClient,
|
282 | 283 | }
|
283 | 284 | // endregion
|
284 | 285 |
|
| 286 | + // region reactive client |
| 287 | + /** |
| 288 | + * Creates a new {@link ReactiveOpenSearchClient} |
| 289 | + * |
| 290 | + * @param clientConfiguration configuration options, must not be {@literal null}. |
| 291 | + * @return the {@link ReactiveOpenSearchClient} |
| 292 | + */ |
| 293 | + public static ReactiveOpenSearchClient createReactive(ClientConfiguration clientConfiguration) { |
| 294 | + |
| 295 | + Assert.notNull(clientConfiguration, "clientConfiguration must not be null"); |
| 296 | + |
| 297 | + return createReactive(getRestClient(clientConfiguration), null, DEFAULT_JSONP_MAPPER); |
| 298 | + } |
| 299 | + |
| 300 | + /** |
| 301 | + * Creates a new {@link ReactiveOpenSearchClient} |
| 302 | + * |
| 303 | + * @param clientConfiguration configuration options, must not be {@literal null}. |
| 304 | + * @param transportOptions options to be added to each request. |
| 305 | + * @return the {@link ReactiveOpenSearchClient} |
| 306 | + */ |
| 307 | + public static ReactiveOpenSearchClient createReactive(ClientConfiguration clientConfiguration, |
| 308 | + @Nullable TransportOptions transportOptions) { |
| 309 | + |
| 310 | + Assert.notNull(clientConfiguration, "ClientConfiguration must not be null!"); |
| 311 | + |
| 312 | + return createReactive(getRestClient(clientConfiguration), transportOptions, DEFAULT_JSONP_MAPPER); |
| 313 | + } |
| 314 | + |
| 315 | + /** |
| 316 | + * Creates a new {@link ReactiveOpenSearchClient} |
| 317 | + * |
| 318 | + * @param clientConfiguration configuration options, must not be {@literal null}. |
| 319 | + * @param transportOptions options to be added to each request. |
| 320 | + * @param jsonpMapper the JsonpMapper to use |
| 321 | + * @return the {@link ReactiveOpenSearchClient} |
| 322 | + */ |
| 323 | + public static ReactiveOpenSearchClient createReactive(ClientConfiguration clientConfiguration, |
| 324 | + @Nullable TransportOptions transportOptions, JsonpMapper jsonpMapper) { |
| 325 | + |
| 326 | + Assert.notNull(clientConfiguration, "ClientConfiguration must not be null!"); |
| 327 | + Assert.notNull(jsonpMapper, "jsonpMapper must not be null"); |
| 328 | + |
| 329 | + return createReactive(getRestClient(clientConfiguration), transportOptions, jsonpMapper); |
| 330 | + } |
| 331 | + |
| 332 | + /** |
| 333 | + * Creates a new {@link ReactiveOpenSearchClient}. |
| 334 | + * |
| 335 | + * @param restClient the underlying {@link RestClient} |
| 336 | + * @return the {@link ReactiveOpenSearchClient} |
| 337 | + */ |
| 338 | + public static ReactiveOpenSearchClient createReactive(RestClient restClient) { |
| 339 | + return createReactive(restClient, null, DEFAULT_JSONP_MAPPER); |
| 340 | + } |
| 341 | + |
| 342 | + /** |
| 343 | + * Creates a new {@link ReactiveOpenSearchClient}. |
| 344 | + * |
| 345 | + * @param restClient the underlying {@link RestClient} |
| 346 | + * @param transportOptions options to be added to each request. |
| 347 | + * @return the {@link ReactiveOpenSearchClient} |
| 348 | + */ |
| 349 | + public static ReactiveOpenSearchClient createReactive(RestClient restClient, |
| 350 | + @Nullable TransportOptions transportOptions, JsonpMapper jsonpMapper) { |
| 351 | + |
| 352 | + Assert.notNull(restClient, "restClient must not be null"); |
| 353 | + |
| 354 | + var transport = getOpenSearchTransport(restClient, REACTIVE_CLIENT, transportOptions, jsonpMapper); |
| 355 | + return createReactive(transport); |
| 356 | + } |
| 357 | + |
| 358 | + /** |
| 359 | + * Creates a new {@link ReactiveOpenSearchClient} that uses the given {@link OpenSearchTransport}. |
| 360 | + * |
| 361 | + * @param transport the transport to use |
| 362 | + * @return the {@link ReactiveOpenSearchClient} |
| 363 | + */ |
| 364 | + public static ReactiveOpenSearchClient createReactive(OpenSearchTransport transport) { |
| 365 | + |
| 366 | + Assert.notNull(transport, "transport must not be null"); |
| 367 | + |
| 368 | + return new ReactiveOpenSearchClient(transport); |
| 369 | + } |
| 370 | + // endregion |
| 371 | + |
| 372 | + |
285 | 373 | private static List<String> formattedHosts(List<InetSocketAddress> hosts, boolean useSsl) {
|
286 | 374 | return hosts.stream().map(it -> (useSsl ? "https" : "http") + "://" + it.getHostString() + ':' + it.getPort())
|
287 | 375 | .collect(Collectors.toList());
|
|
0 commit comments