feat: add configurable request and connection timeouts#30
Open
Onyx2406 wants to merge 2 commits into
Open
Conversation
Add optional request_timeout and connect_timeout fields to ClientConfig. A payment API client without timeouts can hang indefinitely if the server stops responding, which is a production safety concern. Defaults to 30s request timeout and 10s connection timeout via ClientConfig::default(). Can be set to None to disable timeouts.
- Add test verifying client builds and works with custom timeouts - Add test verifying default config has 30s request / 10s connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds optional
request_timeoutandconnect_timeoutfields toClientConfig.Problem: The authenticated client creates a bare
reqwest::Client::new()with no timeouts. In production, a payment API call with no timeout will hang indefinitely if the server stops responding — a safety concern for any financial API client.Solution:
request_timeout: Option<Duration>— overall request timeout (default: 30s viaClientConfig::default())connect_timeout: Option<Duration>— TCP connection timeout (default: 10s viaClientConfig::default())Noneto disable timeoutsThe fields use
#[serde(skip)]sinceDurationdoesn't implementSerialize/Deserializeand timeouts are typically set programmatically, not via config files.Test plan