Class RetryHttpClient

java.lang.Object
com.datastax.astra.internal.http.RetryHttpClient

public class RetryHttpClient extends Object
Http Client using JDK11 client with a retry mechanism.
  • Field Details

    • CONTENT_TYPE_JSON

      public static final String CONTENT_TYPE_JSON
      Headers, Api is usig JSON
      See Also:
    • HEADER_ACCEPT

      public static final String HEADER_ACCEPT
      Header param.
      See Also:
    • HEADER_TOKEN

      public static final String HEADER_TOKEN
      Headers param to insert the token.
      See Also:
    • HEADER_CONTENT_TYPE

      public static final String HEADER_CONTENT_TYPE
      Headers param to insert the conte type.
      See Also:
    • HEADER_AUTHORIZATION

      public static final String HEADER_AUTHORIZATION
      Headers param to insert the token for devops API.
      See Also:
    • HEADER_USER_AGENT

      public static final String HEADER_USER_AGENT
      Headers name to insert the user agent identifying the client.
      See Also:
    • HEADER_REQUESTED_WITH

      public static final String HEADER_REQUESTED_WITH
      Headers param to insert the user agent identifying the client.
      See Also:
    • httpClient

      protected final HttpClient httpClient
      JDK11 Http client.
    • httpClientOptions

      protected final HttpClientOptions httpClientOptions
      Http Options.
    • timeoutOptions

      protected final TimeoutOptions timeoutOptions
      Http Options.
    • retryConfig

      protected final com.evanlennick.retry4j.config.RetryConfig retryConfig
      Default retry configuration.
  • Constructor Details

    • RetryHttpClient

      public RetryHttpClient(HttpClientOptions httpClientOptions, TimeoutOptions timeoutOptions)
      Initialize the instance with all items
      Parameters:
      httpClientOptions - http client options
      timeoutOptions - timeout options
  • Method Details

    • getUserAgentHeader

      public String getUserAgentHeader()
      Give access to the user agent header.
      Returns:
      user agent header
    • parseHttpResponse

      public ApiResponseHttp parseHttpResponse(HttpResponse<String> response)
      Parse HTTP response as a ApiResponseHttp.
      Parameters:
      response - http response from the JDK11 client
      Returns:
      the response as an ApiResponseHttp
    • executeHttpRequest

      public com.evanlennick.retry4j.Status<HttpResponse<String>> executeHttpRequest(HttpRequest req)
      Implementing retries.
      Parameters:
      req - current request
      Returns:
      the closeable response