Class SentinelClient.Builder

java.lang.Object
dev.demeng.sentinel.client.SentinelClient.Builder
Enclosing class:
SentinelClient

public static final class SentinelClient.Builder extends Object
Builder for constructing SentinelClient instances.

Required fields: baseUrl(String) and apiKey(String).

  • Method Details

    • baseUrl

      public SentinelClient.Builder baseUrl(String baseUrl)
      Sets the base URL of the Sentinel API (e.g. "https://your-sentinel-instance.com").
      Parameters:
      baseUrl - the base URL (required)
      Returns:
      this builder
    • apiKey

      public SentinelClient.Builder apiKey(String apiKey)
      Sets the API key used to authenticate requests.
      Parameters:
      apiKey - the API key (required)
      Returns:
      this builder
    • publicKey

      public SentinelClient.Builder publicKey(String publicKey)
      Sets the Base64-encoded Ed25519 public key for response signature verification. When set, all successful validation responses will be cryptographically verified and checked for replay attacks.
      Parameters:
      publicKey - the Base64-encoded Ed25519 public key, or null to disable
      Returns:
      this builder
    • connectTimeout

      public SentinelClient.Builder connectTimeout(Duration connectTimeout)
      Sets the connection timeout. Defaults to 5 seconds.
      Parameters:
      connectTimeout - the connection timeout
      Returns:
      this builder
    • readTimeout

      public SentinelClient.Builder readTimeout(Duration readTimeout)
      Sets the read timeout. Defaults to 10 seconds.
      Parameters:
      readTimeout - the read timeout
      Returns:
      this builder
    • replayProtectionWindow

      public SentinelClient.Builder replayProtectionWindow(Duration replayProtectionWindow)
      Sets the maximum age of a response timestamp for replay protection. Responses with timestamps outside this window are rejected. Defaults to 30 seconds. Only applies when signature verification is enabled.
      Parameters:
      replayProtectionWindow - the replay protection time window
      Returns:
      this builder
    • nonceCacheSize

      public SentinelClient.Builder nonceCacheSize(int nonceCacheSize)
      Sets the maximum number of nonces to cache for replay detection. Defaults to 1000. Only applies when signature verification is enabled.
      Parameters:
      nonceCacheSize - the maximum nonce cache size
      Returns:
      this builder
    • build

      public SentinelClient build()
      Builds and returns a new SentinelClient.
      Returns:
      a configured client instance
      Throws:
      IllegalStateException - if required fields are missing or the public key is invalid