Class Configuration.Builder

java.lang.Object
ch.rasc.jcentserverclient.Configuration.Builder
Enclosing class:
Configuration

public static final class Configuration.Builder extends Object
Builder class for creating Configuration instances.

Provides a fluent API for configuring all aspects of the Centrifugo client. Default values are provided for most settings to ensure the client works out-of-the-box with minimal configuration.

  • Method Details

    • apiKey

      public Configuration.Builder apiKey(String apiKey)
      Sets the API key for authenticating with Centrifugo.

      The API key is sent in the X-API-Key header with each request. This key must match the http_api.key configuration in your Centrifugo server configuration.

      Parameters:
      apiKey - the API key for authentication
      Returns:
      this builder instance
      See Also:
    • baseUrl

      public Configuration.Builder baseUrl(String baseUrl)
      Sets the base URL for the Centrifugo server API.

      Should include the protocol, host, port, and path to the API endpoint. Typically this will be something like http://localhost:8000/api or https://centrifugo.example.com/api.

      Parameters:
      baseUrl - the base URL for API calls
      Returns:
      this builder instance
    • client

      public Configuration.Builder client(feign.Client client)
      Sets the HTTP client implementation to use.

      Allows customization of the underlying HTTP client. If not set, a default HTTP/2 client will be used.

      Parameters:
      client - the HTTP client implementation
      Returns:
      this builder instance
    • retryer

      public Configuration.Builder retryer(feign.Retryer retryer)
      Sets the retry policy for failed requests.

      Configures how the client should handle request failures and retries. If not set, a default retry policy will be used.

      Parameters:
      retryer - the retry policy implementation
      Returns:
      this builder instance
    • feignOptions

      public Configuration.Builder feignOptions(feign.Request.Options feignOptions)
      Sets the HTTP request options including timeouts.

      Configures connection and read timeouts for HTTP requests. Default timeouts are usually sufficient for most use cases.

      Parameters:
      feignOptions - the HTTP request options
      Returns:
      this builder instance
    • logger

      public Configuration.Builder logger(feign.Logger logger)
      Sets the logger implementation for HTTP request/response logging.

      Useful for debugging API interactions. If not set, SLF4J logger will be used by default.

      Parameters:
      logger - the logger implementation
      Returns:
      this builder instance
    • errorDecoder

      public Configuration.Builder errorDecoder(feign.codec.ErrorDecoder errorDecoder)
      Sets the error decoder for handling HTTP error responses.

      Customizes how HTTP error responses are converted to Java exceptions. If not set, a default error decoder will be used.

      Parameters:
      errorDecoder - the error decoder implementation
      Returns:
      this builder instance
    • additionalRequestInterceptor

      public Configuration.Builder additionalRequestInterceptor(feign.RequestInterceptor additionalRequestInterceptor)
      Sets an additional request interceptor.

      Allows adding custom headers or modifying requests before they are sent to the server. This is applied in addition to the built-in API key interceptor.

      Parameters:
      additionalRequestInterceptor - the request interceptor
      Returns:
      this builder instance
    • logLevel

      public Configuration.Builder logLevel(feign.Logger.Level logLevel)
      Sets the logging level for HTTP requests and responses.

      Controls how much detail is logged about HTTP interactions. Options include NONE, BASIC, HEADERS, and FULL.

      Parameters:
      logLevel - the logging level
      Returns:
      this builder instance
    • build

      public Configuration build()
      Builds the configuration instance with the specified settings.

      Applies default values for any settings that were not explicitly configured.

      Returns:
      a new Configuration instance