Skip to content

Commit 8f86cd9

Browse files
committed
fix: verifier retry logic
Adjust the logic retry logic in the Pact Verifier so that it: - Retries on 5XX server errors, 429 Too Many Requests, and 408 Request Timeout. - In the case of a 429, also parse the `Retry-After` header (if present) for the delay - Tweak the exponential retry delay from millisecond decades starting from 1ms, to powers of 2 starting from 0.5s. It is unlikely that a 1ms delay will resolve the issue, but also going from 1s to 10s to 100s is quite a large increase. Also took the opportunity to upgrade reqwest to 0.13. Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent 9f10078 commit 8f86cd9

4 files changed

Lines changed: 359 additions & 81 deletions

File tree

rust/Cargo.lock

Lines changed: 24 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/pact_verifier/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pact_matching = { version = "~2.0.3", path = "../pact_matching", default-feature
3939
pact_models = { version = "~1.3.10", default-features = false }
4040
pact-plugin-driver = { version = "~0.7.5", optional = true, default-features = false }
4141
regex = "1.12.3"
42-
reqwest = { version = "0.12.28", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] }
42+
httpdate = "1.0"
43+
reqwest = { version = "0.13", default-features = false, features = ["rustls", "blocking", "json", "query"] }
4344
serde = "1.0.228"
4445
serde_json = "1.0.149"
4546
serde_with = { version = "3.16.1", features = ["json"] }
@@ -54,6 +55,7 @@ urlencoding = "2.1.3"
5455
crate-type = ["cdylib", "rlib"]
5556

5657
[dev-dependencies]
58+
axum = "0.8"
5759
chrono = "0.4.43"
5860
chrono-tz = "0.10.4"
5961
env_logger = "0.11.9"

rust/pact_verifier/src/pact_broker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl HALClientBuilder {
215215
self
216216
}
217217

218-
/// Sets the number of retries on certain HTTP errors. Default is 3.
218+
/// Sets the number of retries on certain HTTP errors (5xx, 408, 429). Default is 3.
219219
pub fn with_retries(&mut self, retries: u8) -> &mut Self {
220220
self.retries = retries;
221221
self

0 commit comments

Comments
 (0)