Package dev.sympho.bot_utils
Class HttpClientUtils
java.lang.Object
dev.sympho.bot_utils.HttpClientUtils
Utilities for using HTTP clients.
- Since:
- 1.0
- Version:
- 1.0
- API Note:
- Useful for configuring the HTTP clients used for Discord.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEndpoint types used to interact with Discord. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCreates a function that adds DNS retry capabilities to a connection mono, using thedefault retry policy.static reactor.netty.http.client.HttpClientaddDnsRetry(reactor.netty.http.client.HttpClient client) Adds DNS retry capabilities to an HTTP client, using thedefault retry policy.static reactor.netty.http.client.HttpClientaddDnsRetry(reactor.netty.http.client.HttpClient client, Retry retryPolicy) Adds DNS retry capabilities to an HTTP client.addDnsRetry(Retry retryPolicy) Creates a function that adds DNS retry capabilities to a connection mono.static reactor.netty.http.client.HttpClientenableMetrics(reactor.netty.http.client.HttpClient client, HttpClientUtils.EndpointType type) Enables metrics on an HTTP client.
-
Field Details
-
DEFAULT_DNS_RETRY_POLICY
The default DNS retry policy.
-
-
Method Details
-
addDnsRetry
public static Function<Mono<? extends reactor.netty.Connection>,Mono<? extends reactor.netty.Connection>> addDnsRetry(Retry retryPolicy) Creates a function that adds DNS retry capabilities to a connection mono.- Parameters:
retryPolicy- The retry policy to use.- Returns:
- The conversion function.
- API Note:
- Use with
HttpClient.mapConnect(java.util.function.Function).
-
addDnsRetry
public static Function<Mono<? extends reactor.netty.Connection>,Mono<? extends reactor.netty.Connection>> addDnsRetry()Creates a function that adds DNS retry capabilities to a connection mono, using thedefault retry policy.- Returns:
- The conversion function.
- See Also:
- API Note:
- Use with
HttpClient.mapConnect(java.util.function.Function).
-
addDnsRetry
public static reactor.netty.http.client.HttpClient addDnsRetry(reactor.netty.http.client.HttpClient client, Retry retryPolicy) Adds DNS retry capabilities to an HTTP client.- Parameters:
client- The client to configure.retryPolicy- The retry policy to use.- Returns:
- The configured client.
- API Note:
- This is a convenience shortcut for calling
HttpClient.mapConnect(java.util.function.Function)with the result ofaddDnsRetry(Retry); it is equivalent toclient.mapConnect(HttpClientUtils.addDnsRetry(retryPolicy)).
-
addDnsRetry
public static reactor.netty.http.client.HttpClient addDnsRetry(reactor.netty.http.client.HttpClient client) Adds DNS retry capabilities to an HTTP client, using thedefault retry policy.- Parameters:
client- The client to configure.- Returns:
- The configured client.
- See Also:
- API Note:
- This is equivalent to
HttpClientUtils.addDnsRetry(client, HttpClientUtils.DEFAULT_DNS_RETRY_POLICY).
-
enableMetrics
public static reactor.netty.http.client.HttpClient enableMetrics(reactor.netty.http.client.HttpClient client, HttpClientUtils.EndpointType type) Enables metrics on an HTTP client.- Parameters:
client- The client to configure.type- The type of endpoint being used with that client.- Returns:
- The configured client.
-