Skip to content

Commit

Permalink
refactor: Move all backoff in one mod (#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Aug 23, 2024
1 parent d430103 commit af57964
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/constant.rs → src/backoff/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use crate::backoff::BackoffBuilder;
use crate::constant::ConstantBuilder;
use crate::BackoffBuilder;
use crate::ConstantBuilder;

#[test]
fn test_constant_default() {
Expand Down
4 changes: 2 additions & 2 deletions src/exponential.rs → src/backoff/exponential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use crate::backoff::BackoffBuilder;
use crate::exponential::ExponentialBuilder;
use crate::BackoffBuilder;
use crate::ExponentialBuilder;

#[test]
fn test_exponential_default() {
Expand Down
4 changes: 2 additions & 2 deletions src/fibonacci.rs → src/backoff/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use crate::backoff::BackoffBuilder;
use crate::fibonacci::FibonacciBuilder;
use crate::BackoffBuilder;
use crate::FibonacciBuilder;

#[test]
fn test_fibonacci_default() {
Expand Down
14 changes: 14 additions & 0 deletions src/backoff/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod api;
pub use api::*;

mod constant;
pub use constant::ConstantBackoff;
pub use constant::ConstantBuilder;

mod fibonacci;
pub use fibonacci::FibonacciBackoff;
pub use fibonacci::FibonacciBuilder;

mod exponential;
pub use exponential::ExponentialBackoff;
pub use exponential::ExponentialBuilder;
2 changes: 1 addition & 1 deletion src/blocking_retry_with_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod tests {
use std::sync::Mutex;

use super::*;
use crate::exponential::ExponentialBuilder;
use crate::ExponentialBuilder;
use anyhow::Result;

struct Test;
Expand Down
15 changes: 1 addition & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,7 @@
#![deny(unused_qualifications)]

mod backoff;
pub use backoff::Backoff;
pub use backoff::BackoffBuilder;

mod constant;
pub use constant::ConstantBackoff;
pub use constant::ConstantBuilder;

mod exponential;
pub use exponential::ExponentialBackoff;
pub use exponential::ExponentialBuilder;

mod fibonacci;
pub use fibonacci::FibonacciBackoff;
pub use fibonacci::FibonacciBuilder;
pub use backoff::*;

mod retry;
pub use retry::Retry;
Expand Down
2 changes: 1 addition & 1 deletion src/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod tests {
use tokio::test;

use super::*;
use crate::exponential::ExponentialBuilder;
use crate::ExponentialBuilder;

async fn always_error() -> anyhow::Result<()> {
Err(anyhow::anyhow!("test_query meets error"))
Expand Down
2 changes: 1 addition & 1 deletion src/retry_with_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ mod tests {
use tokio::test;

use super::*;
use crate::exponential::ExponentialBuilder;
use crate::ExponentialBuilder;

struct Test;

Expand Down

0 comments on commit af57964

Please sign in to comment.