Package dev.dosya.sdk
Class DosyaClientOptions
java.lang.Object
dev.dosya.sdk.DosyaClientOptions
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 Summary
ConstructorsConstructorDescriptionDosyaClientOptions(@NotNull String apiKey) Creates options with the given API key. -
Method Summary
Modifier and TypeMethodDescriptionbaseDelay(long baseDelay) Sets the initial delay for exponential backoff in milliseconds.Sets the base URL for the Dosya API.connectTimeout(long connectTimeout) Sets the TCP connection timeout in milliseconds.Registers a debug callback that receives human-readable log messages.@NotNull StringReturns the API key.longReturns the base delay for exponential backoff in milliseconds.@NotNull StringReturns the base URL.longReturns the TCP connection timeout in milliseconds.getDebug()Returns the debug callback, or null.@Nullable DosyaInterceptorReturns the interceptor, or null.longReturns the maximum retry delay in milliseconds.intReturns the maximum retry count.@Nullable Consumer<RateLimitInfo>Returns the rate-limit callback, or null.longReturns the read/response timeout in milliseconds.interceptor(@Nullable DosyaInterceptor interceptor) Registers an interceptor for observing HTTP requests and responses.maxDelay(long maxDelay) Sets the maximum delay between retries in milliseconds.maxRetries(int maxRetries) Sets the maximum number of retry attempts for failed requests.onRateLimit(@Nullable Consumer<RateLimitInfo> onRateLimit) Registers a callback invoked when rate-limit response headers are received.readTimeout(long readTimeout) Sets the read/response timeout in milliseconds.timeout(long timeout) Convenience method that sets both connect and read timeouts to the same value.toString()
-
Constructor Details
-
DosyaClientOptions
Creates options with the given API key.- Parameters:
apiKey- the Dosya API key (must start withdos_)- Throws:
IllegalArgumentException- if the API key is null or empty
-
-
Method Details
-
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
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
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
Sets the maximum delay between retries in milliseconds.- Parameters:
maxDelay- the maximum delay in ms (default 30000)- Returns:
- this options instance for chaining
-
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
Sets the TCP connection timeout in milliseconds.- Parameters:
connectTimeout- the connect timeout in ms (default 10000)- Returns:
- this options instance for chaining
-
readTimeout
Sets the read/response timeout in milliseconds.- Parameters:
readTimeout- the read timeout in ms (default 30000)- Returns:
- this options instance for chaining
-
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
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
Registers an interceptor for observing HTTP requests and responses.- Parameters:
interceptor- the interceptor, or null to disable- Returns:
- this options instance for chaining
-
getApiKey
Returns the API key. -
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
Returns the rate-limit callback, or null. -
getDebug
Returns the debug callback, or null. -
getInterceptor
Returns the interceptor, or null. -
toString
-