Package dev.dosya.sdk

Class DosyaClientOptions

java.lang.Object
dev.dosya.sdk.DosyaClientOptions

public final class DosyaClientOptions extends Object
Configuration options for DosyaClient.

Use the fluent builder methods to customize behaviour:


 DosyaClientOptions options = new DosyaClientOptions("dos_your_key")
     .connectTimeout(5000)
     .readTimeout(30000)
     .maxRetries(5);
 

Thread-safe after construction. Do not mutate after passing to DosyaClient.

Since:
0.1.0
  • Constructor Details

    • DosyaClientOptions

      public DosyaClientOptions(@NotNull @NotNull String apiKey)
      Creates options with the given API key.
      Parameters:
      apiKey - the Dosya API key (must start with dos_)
      Throws:
      IllegalArgumentException - if the API key is null or empty
  • Method Details

    • baseUrl

      public DosyaClientOptions baseUrl(@NotNull @NotNull String baseUrl)
      Sets the base URL for the Dosya API. Must use HTTPS.
      Parameters:
      baseUrl - the base URL (e.g. https://dosya.dev)
      Returns:
      this options instance for chaining
      Throws:
      IllegalArgumentException - if the URL does not use HTTPS
    • maxRetries

      public DosyaClientOptions maxRetries(int maxRetries)
      Sets the maximum number of retry attempts for failed requests.
      Parameters:
      maxRetries - the maximum number of retries (default 3)
      Returns:
      this options instance for chaining
    • baseDelay

      public DosyaClientOptions baseDelay(long baseDelay)
      Sets the initial delay for exponential backoff in milliseconds.
      Parameters:
      baseDelay - the base delay in ms (default 500)
      Returns:
      this options instance for chaining
    • maxDelay

      public DosyaClientOptions maxDelay(long maxDelay)
      Sets the maximum delay between retries in milliseconds.
      Parameters:
      maxDelay - the maximum delay in ms (default 30000)
      Returns:
      this options instance for chaining
    • timeout

      public DosyaClientOptions timeout(long timeout)
      Convenience method that sets both connect and read timeouts to the same value.
      Parameters:
      timeout - the timeout in ms for both connect and read
      Returns:
      this options instance for chaining
    • connectTimeout

      public DosyaClientOptions connectTimeout(long connectTimeout)
      Sets the TCP connection timeout in milliseconds.
      Parameters:
      connectTimeout - the connect timeout in ms (default 10000)
      Returns:
      this options instance for chaining
    • readTimeout

      public DosyaClientOptions readTimeout(long readTimeout)
      Sets the read/response timeout in milliseconds.
      Parameters:
      readTimeout - the read timeout in ms (default 30000)
      Returns:
      this options instance for chaining
    • onRateLimit

      public DosyaClientOptions onRateLimit(@Nullable @Nullable Consumer<RateLimitInfo> onRateLimit)
      Registers a callback invoked when rate-limit response headers are received.
      Parameters:
      onRateLimit - the callback, or null to disable
      Returns:
      this options instance for chaining
    • debug

      public DosyaClientOptions debug(@Nullable @Nullable Consumer<String> debug)
      Registers a debug callback that receives human-readable log messages.
      Parameters:
      debug - the callback, or null to disable
      Returns:
      this options instance for chaining
    • interceptor

      public DosyaClientOptions interceptor(@Nullable @Nullable DosyaInterceptor interceptor)
      Registers an interceptor for observing HTTP requests and responses.
      Parameters:
      interceptor - the interceptor, or null to disable
      Returns:
      this options instance for chaining
    • getApiKey

      @NotNull public @NotNull String getApiKey()
      Returns the API key.
    • getBaseUrl

      @NotNull public @NotNull String getBaseUrl()
      Returns the base URL.
    • getMaxRetries

      public int getMaxRetries()
      Returns the maximum retry count.
    • getBaseDelay

      public long getBaseDelay()
      Returns the base delay for exponential backoff in milliseconds.
    • getMaxDelay

      public long getMaxDelay()
      Returns the maximum retry delay in milliseconds.
    • getConnectTimeout

      public long getConnectTimeout()
      Returns the TCP connection timeout in milliseconds.
    • getReadTimeout

      public long getReadTimeout()
      Returns the read/response timeout in milliseconds.
    • getOnRateLimit

      @Nullable public @Nullable Consumer<RateLimitInfo> getOnRateLimit()
      Returns the rate-limit callback, or null.
    • getDebug

      @Nullable public @Nullable Consumer<String> getDebug()
      Returns the debug callback, or null.
    • getInterceptor

      @Nullable public @Nullable DosyaInterceptor getInterceptor()
      Returns the interceptor, or null.
    • toString

      public String toString()
      Overrides:
      toString in class Object