Package dev.demeng.sentinel.client
Class SentinelClient.Builder
java.lang.Object
dev.demeng.sentinel.client.SentinelClient.Builder
- Enclosing class:
- SentinelClient
Builder for constructing
SentinelClient instances.
Required fields: baseUrl(String) and apiKey(String).
-
Method Summary
Modifier and TypeMethodDescriptionSets the API key used to authenticate requests.Sets the base URL of the Sentinel API (e.g.build()Builds and returns a newSentinelClient.connectTimeout(Duration connectTimeout) Sets the connection timeout.nonceCacheSize(int nonceCacheSize) Sets the maximum number of nonces to cache for replay detection.Sets the Base64-encoded Ed25519 public key for response signature verification.readTimeout(Duration readTimeout) Sets the read timeout.replayProtectionWindow(Duration replayProtectionWindow) Sets the maximum age of a response timestamp for replay protection.
-
Method Details
-
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
Sets the API key used to authenticate requests.- Parameters:
apiKey- the API key (required)- Returns:
- this builder
-
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, ornullto disable- Returns:
- this builder
-
connectTimeout
Sets the connection timeout. Defaults to 5 seconds.- Parameters:
connectTimeout- the connection timeout- Returns:
- this builder
-
readTimeout
Sets the read timeout. Defaults to 10 seconds.- Parameters:
readTimeout- the read timeout- Returns:
- this builder
-
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
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
Builds and returns a newSentinelClient.- Returns:
- a configured client instance
- Throws:
IllegalStateException- if required fields are missing or the public key is invalid
-