Class HttpClientUtils

java.lang.Object
dev.sympho.bot_utils.HttpClientUtils

public final class HttpClientUtils extends Object
Utilities for using HTTP clients.
Since:
1.0
Version:
1.0
API Note:
Useful for configuring the HTTP clients used for Discord.
  • Field Details

    • DEFAULT_DNS_RETRY_POLICY

      public static final Retry 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 the default 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 of addDnsRetry(Retry); it is equivalent to client.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 the default 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.