Skip to content

Commit 63a2768

Browse files
SK-3002 add README docs for configurable timeouts and retries (#370)
Document the timeout/retry settings introduced in Release/26.7.15: - client-wide config on Skyflow.builder() and per-vault config on VaultConfig - settings table (timeout, maxRetries, initialRetryDelayMillis, maxRetryDelayMillis) with units/defaults - precedence (per-vault > client-wide > default, resolved per field) - retry behavior (408/429/5xx, backoff+jitter, Retry-After/X-RateLimit-Reset) and 408 timeout error Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bc80733 commit 63a2768

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,56 @@ Notes:
173173
- If neither Skyflow common credentials nor individual configuration-level credentials are provided, the SDK attempts to retrieve credentials from the `SKYFLOW_CREDENTIALS` environment variable.
174174
- All Vault operations require a client instance.
175175

176+
### Configure timeouts and retries
177+
178+
You can control how long a request is allowed to run and whether failed requests are retried. These settings can be applied client-wide (to all vaults) on `Skyflow.builder()`, or per vault on `VaultConfig`.
179+
180+
| Setting | Unit | Default | Description |
181+
| --- | --- | --- | --- |
182+
| `timeout` | seconds | `60` | Overall time budget for a request, including any retries and backoff. |
183+
| `maxRetries` | count | `0` | Number of retry attempts. `0` disables retries. |
184+
| `initialRetryDelayMillis` | milliseconds | `500` | Base delay before the first retry. |
185+
| `maxRetryDelayMillis` | milliseconds | `2000` | Upper bound on the delay between retries. |
186+
187+
Each setting is available at two levels:
188+
189+
- **Client-wide** — on `Skyflow.builder()`: `.timeout(int)`, `.maxRetries(int)`, `.initialRetryDelayMillis(long)`, `.maxRetryDelayMillis(long)`. Applies to every vault.
190+
- **Per vault** — on `VaultConfig`: `.setTimeout(int)`, `.setMaxRetries(int)`, `.setInitialRetryDelayMillis(long)`, `.setMaxRetryDelayMillis(long)`. Applies to that vault only.
191+
192+
**Precedence:** a value set on `VaultConfig` (per vault) overrides the client-wide value set on `Skyflow.builder()`, which overrides the SDK default. Resolution is per field, so a vault can override just `timeout` and still inherit the client-wide retry settings.
193+
194+
**Retry behavior:** when `maxRetries` is greater than `0`, the SDK retries requests that fail with HTTP `408`, `429`, or `5xx`, using exponential backoff with jitter between `initialRetryDelayMillis` and `maxRetryDelayMillis`. It also honors the `Retry-After` and `X-RateLimit-Reset` response headers. Retries are disabled by default so non-idempotent writes are not automatically retried; enable them explicitly when appropriate.
195+
196+
**Timeouts:** when a request exceeds `timeout`, the SDK surfaces an error with HTTP status `408` and the message `Request timed out.`.
197+
198+
```java
199+
import com.skyflow.Skyflow;
200+
import com.skyflow.config.VaultConfig;
201+
202+
// Per-vault configuration: these settings override the client-wide values for this vault only.
203+
VaultConfig vaultConfig = new VaultConfig();
204+
vaultConfig.setVaultId("<VAULT_ID>");
205+
vaultConfig.setClusterId("<CLUSTER_ID>");
206+
vaultConfig.setEnv(Env.PROD);
207+
vaultConfig.setCredentials(credentials);
208+
vaultConfig.setTimeout(30); // seconds — overall request timeout
209+
vaultConfig.setMaxRetries(3); // retry attempts (0 = retries off)
210+
vaultConfig.setInitialRetryDelayMillis(1000L); // base backoff in milliseconds
211+
vaultConfig.setMaxRetryDelayMillis(4000L); // backoff cap in milliseconds
212+
213+
// Client-wide defaults: apply to every vault unless overridden on the vault (as above).
214+
Skyflow skyflowClient = Skyflow.builder()
215+
.timeout(60) // seconds — overall request timeout
216+
.maxRetries(2) // retry attempts (0 = retries off)
217+
.initialRetryDelayMillis(500L) // base backoff in milliseconds
218+
.maxRetryDelayMillis(2000L) // backoff cap in milliseconds
219+
.addVaultConfig(vaultConfig)
220+
.build();
221+
222+
// Result for this vault: timeout=30, maxRetries=3, initialRetryDelayMillis=1000, maxRetryDelayMillis=4000
223+
// (all overridden per vault). A vault that sets none of these inherits the client-wide values above.
224+
```
225+
176226
# Vault
177227

178228
The [Vault](https://github.com/skyflowapi/skyflow-java/tree/main/src/main/java/com/skyflow/vault) module performs operations on the vault, including inserting records and detokenizing tokens.

0 commit comments

Comments
 (0)