diff --git a/Cargo.lock b/Cargo.lock index f6d11d80f..d4d511e04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,7 +103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" dependencies = [ "async-lock 2.8.0", - "autocfg 1.3.0", + "autocfg", "blocking", "futures-lite 1.13.0", ] @@ -130,7 +130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock 2.8.0", - "autocfg 1.3.0", + "autocfg", "cfg-if", "concurrent-queue", "futures-lite 1.13.0", @@ -278,15 +278,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.3.0", -] - [[package]] name = "autocfg" version = "1.3.0" @@ -294,13 +285,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] -name = "backoff" -version = "0.1.6" +name = "backon" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66483433ebf577e03c6546df761778e4cc40b00e5a1ea7ed850733ffb555d71f" +checksum = "e4fa97bb310c33c811334143cf64c5bb2b7b3c06e453db6b095d7061eff8f113" dependencies = [ - "instant", - "rand 0.6.5", + "fastrand 2.1.1", ] [[package]] @@ -407,15 +397,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "cmake" version = "0.1.51" @@ -958,7 +939,7 @@ version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "autocfg 1.3.0", + "autocfg", ] [[package]] @@ -1070,7 +1051,7 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ - "autocfg 1.3.0", + "autocfg", "bitflags 1.3.2", "cfg-if", "concurrent-queue", @@ -1146,35 +1127,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - [[package]] name = "rand_core" version = "0.3.1" @@ -1190,74 +1142,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rdkafka" version = "0.36.2" dependencies = [ "async-std", - "backoff", + "backon", "chrono", "clap", "env_logger", @@ -1450,7 +1340,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "autocfg 1.3.0", + "autocfg", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b9045ce58..04df91504 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ tracing = { version = "0.1.30", optional = true } [dev-dependencies] async-std = { version = "1.9.0", features = ["attributes"] } -backoff = "0.1.5" +backon = { version = "1.2", default-features = false, features = ["std-blocking-sleep"] } chrono = "0.4.0" clap = "2.18.0" env_logger = "0.9.0" diff --git a/tests/test_admin.rs b/tests/test_admin.rs index 4cf0e9a81..5c4e4eeef 100644 --- a/tests/test_admin.rs +++ b/tests/test_admin.rs @@ -2,7 +2,7 @@ use std::time::Duration; -use backoff::{ExponentialBackoff, Operation}; +use backon::{BlockingRetryable, ExponentialBuilder}; use rdkafka::admin::{ AdminClient, AdminOptions, AlterConfig, ConfigEntry, ConfigSource, GroupResult, NewPartitions, @@ -75,10 +75,6 @@ fn fetch_metadata(topic: &str) -> Metadata { create_config().create().expect("consumer creation failed"); let timeout = Some(Duration::from_secs(1)); - let mut backoff = ExponentialBackoff { - max_elapsed_time: Some(Duration::from_secs(5)), - ..Default::default() - }; (|| { let metadata = consumer .fetch_metadata(Some(topic), timeout) @@ -90,9 +86,10 @@ fn fetch_metadata(topic: &str) -> Metadata { if topic.partitions().is_empty() { Err("metadata fetch returned a topic with no partitions".to_string())? } - Ok(metadata) + Ok::<_, String>(metadata) }) - .retry(&mut backoff) + .retry(ExponentialBuilder::default().with_max_delay(Duration::from_secs(5))) + .call() .unwrap() } @@ -101,10 +98,6 @@ fn verify_delete(topic: &str) { create_config().create().expect("consumer creation failed"); let timeout = Some(Duration::from_secs(1)); - let mut backoff = ExponentialBackoff { - max_elapsed_time: Some(Duration::from_secs(5)), - ..Default::default() - }; (|| { // Asking about the topic specifically will recreate it (under the // default Kafka configuration, at least) so we have to ask for the list @@ -115,9 +108,10 @@ fn verify_delete(topic: &str) { if metadata.topics().iter().any(|t| t.name() == topic) { Err(format!("topic {} still exists", topic))? } - Ok(()) + Ok::<(), String>(()) }) - .retry(&mut backoff) + .retry(ExponentialBuilder::default().with_max_delay(Duration::from_secs(5))) + .call() .unwrap() }