From b333a9eb33c9754d57d08890056ddce29235039b Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 27 Aug 2024 12:27:41 +0800 Subject: [PATCH] chore: Make backon a workspace Signed-off-by: Xuanwo --- .github/workflows/ci.yml | 9 +-- Cargo.toml | 55 ++----------------- backon/Cargo.toml | 54 ++++++++++++++++++ {src => backon/src}/backoff/api.rs | 0 {src => backon/src}/backoff/constant.rs | 0 {src => backon/src}/backoff/exponential.rs | 0 {src => backon/src}/backoff/fibonacci.rs | 0 {src => backon/src}/backoff/mod.rs | 0 {src => backon/src}/blocking_retry.rs | 0 .../src}/blocking_retry_with_context.rs | 0 {src => backon/src}/docs/examples/basic.md | 0 {src => backon/src}/docs/examples/closure.md | 0 .../src}/docs/examples/inside_mut_self.md | 0 {src => backon/src}/docs/examples/mod.rs | 0 {src => backon/src}/docs/examples/sqlx.md | 0 .../src}/docs/examples/with_args.md | 0 .../src}/docs/examples/with_mut_self.md | 0 .../src}/docs/examples/with_self.md | 0 .../src}/docs/examples/with_specific_error.md | 0 {src => backon/src}/docs/mod.rs | 0 {src => backon/src}/lib.rs | 0 {src => backon/src}/retry.rs | 0 {src => backon/src}/retry_with_context.rs | 0 {src => backon/src}/sleep.rs | 0 24 files changed, 64 insertions(+), 54 deletions(-) create mode 100644 backon/Cargo.toml rename {src => backon/src}/backoff/api.rs (100%) rename {src => backon/src}/backoff/constant.rs (100%) rename {src => backon/src}/backoff/exponential.rs (100%) rename {src => backon/src}/backoff/fibonacci.rs (100%) rename {src => backon/src}/backoff/mod.rs (100%) rename {src => backon/src}/blocking_retry.rs (100%) rename {src => backon/src}/blocking_retry_with_context.rs (100%) rename {src => backon/src}/docs/examples/basic.md (100%) rename {src => backon/src}/docs/examples/closure.md (100%) rename {src => backon/src}/docs/examples/inside_mut_self.md (100%) rename {src => backon/src}/docs/examples/mod.rs (100%) rename {src => backon/src}/docs/examples/sqlx.md (100%) rename {src => backon/src}/docs/examples/with_args.md (100%) rename {src => backon/src}/docs/examples/with_mut_self.md (100%) rename {src => backon/src}/docs/examples/with_self.md (100%) rename {src => backon/src}/docs/examples/with_specific_error.md (100%) rename {src => backon/src}/docs/mod.rs (100%) rename {src => backon/src}/lib.rs (100%) rename {src => backon/src}/retry.rs (100%) rename {src => backon/src}/retry_with_context.rs (100%) rename {src => backon/src}/sleep.rs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07287e3..fb4b4f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - name: Format run: cargo fmt --all -- --check - name: Clippy - run: cargo clippy --all-features --all-targets -- -D warnings + run: cargo clippy --workspace --all-features --all-targets -- -D warnings msrv-check: runs-on: ubuntu-latest @@ -33,7 +33,7 @@ jobs: - name: Install run: rustup toolchain install ${BACKON_MSRV} - name: Check MSRV - run: cargo +${BACKON_MSRV} build + run: cargo +${BACKON_MSRV} build --workspace env: RUST_LOG: DEBUG RUST_BACKTRACE: full @@ -49,7 +49,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Test - run: cargo test --all-features + run: cargo test --all-features --workspace env: RUST_LOG: DEBUG RUST_BACKTRACE: full @@ -60,7 +60,7 @@ jobs: - uses: actions/checkout@v4 - run: rustup toolchain install nightly - name: Test - run: cargo +nightly test --all-features + run: cargo +nightly test --all-features --workspace env: RUST_LOG: DEBUG RUST_BACKTRACE: full @@ -73,6 +73,7 @@ jobs: - name: Install run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - run: wasm-pack test --node --all-features -- --skip blocking + working-directory: backon env: RUST_LOG: DEBUG RUST_BACKTRACE: full diff --git a/Cargo.toml b/Cargo.toml index 7e97701..56b1302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,53 +1,8 @@ -[package] -description = "Make retry like a built-in feature provided by Rust." -documentation = "https://docs.rs/backon" +[workspace] +members = ["backon"] +resolver = "2" + +[workspace.package] edition = "2021" license = "Apache-2.0" -name = "backon" repository = "https://github.com/Xuanwo/backon" -rust-version = "1.70" -version = "1.0.2" - -[package.metadata.docs.rs] -all-features = true -targets = [ - "x86_64-unknown-linux-gnu", - "x86_64-apple-darwin", - "x86_64-pc-windows-msvc", - "wasm32-unknown-unknown", -] - -[features] -gloo-timers-sleep = ["dep:gloo-timers", "gloo-timers?/futures"] -tokio-sleep = ["dep:tokio", "tokio?/time"] - -[dependencies] -fastrand = "2.0.0" - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio = { version = "1", optional = true } - -[target.'cfg(target_arch = "wasm32")'.dependencies] -gloo-timers = { version = "0.3", optional = true } - -[dev-dependencies] -anyhow = "1" -reqwest = "0.12" - -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] -tokio = { version = "1", features = [ - "macros", - "rt", - "sync", -], default-features = false } -wasm-bindgen-test = "0.3" - -[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -sqlx = { version = "0.8.0", features = ["runtime-tokio", "sqlite"] } -tokio = { version = "1", features = [ - "time", - "rt", - "macros", - "sync", - "rt-multi-thread", -] } diff --git a/backon/Cargo.toml b/backon/Cargo.toml new file mode 100644 index 0000000..842758a --- /dev/null +++ b/backon/Cargo.toml @@ -0,0 +1,54 @@ +[package] +description = "Make retry like a built-in feature provided by Rust." +documentation = "https://docs.rs/backon" +name = "backon" +rust-version = "1.70" +version = "1.0.2" + +edition.workspace = true +license.workspace = true +repository.workspace = true + +[package.metadata.docs.rs] +all-features = true +targets = [ + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "wasm32-unknown-unknown", +] + +[features] +gloo-timers-sleep = ["dep:gloo-timers", "gloo-timers?/futures"] +tokio-sleep = ["dep:tokio", "tokio?/time"] + +[dependencies] +fastrand = "2.0.0" + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tokio = { version = "1", optional = true } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +gloo-timers = { version = "0.3", optional = true } + +[dev-dependencies] +anyhow = "1" +reqwest = "0.12" + +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +tokio = { version = "1", features = [ + "macros", + "rt", + "sync", +], default-features = false } +wasm-bindgen-test = "0.3" + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +sqlx = { version = "0.8.0", features = ["runtime-tokio", "sqlite"] } +tokio = { version = "1", features = [ + "time", + "rt", + "macros", + "sync", + "rt-multi-thread", +] } diff --git a/src/backoff/api.rs b/backon/src/backoff/api.rs similarity index 100% rename from src/backoff/api.rs rename to backon/src/backoff/api.rs diff --git a/src/backoff/constant.rs b/backon/src/backoff/constant.rs similarity index 100% rename from src/backoff/constant.rs rename to backon/src/backoff/constant.rs diff --git a/src/backoff/exponential.rs b/backon/src/backoff/exponential.rs similarity index 100% rename from src/backoff/exponential.rs rename to backon/src/backoff/exponential.rs diff --git a/src/backoff/fibonacci.rs b/backon/src/backoff/fibonacci.rs similarity index 100% rename from src/backoff/fibonacci.rs rename to backon/src/backoff/fibonacci.rs diff --git a/src/backoff/mod.rs b/backon/src/backoff/mod.rs similarity index 100% rename from src/backoff/mod.rs rename to backon/src/backoff/mod.rs diff --git a/src/blocking_retry.rs b/backon/src/blocking_retry.rs similarity index 100% rename from src/blocking_retry.rs rename to backon/src/blocking_retry.rs diff --git a/src/blocking_retry_with_context.rs b/backon/src/blocking_retry_with_context.rs similarity index 100% rename from src/blocking_retry_with_context.rs rename to backon/src/blocking_retry_with_context.rs diff --git a/src/docs/examples/basic.md b/backon/src/docs/examples/basic.md similarity index 100% rename from src/docs/examples/basic.md rename to backon/src/docs/examples/basic.md diff --git a/src/docs/examples/closure.md b/backon/src/docs/examples/closure.md similarity index 100% rename from src/docs/examples/closure.md rename to backon/src/docs/examples/closure.md diff --git a/src/docs/examples/inside_mut_self.md b/backon/src/docs/examples/inside_mut_self.md similarity index 100% rename from src/docs/examples/inside_mut_self.md rename to backon/src/docs/examples/inside_mut_self.md diff --git a/src/docs/examples/mod.rs b/backon/src/docs/examples/mod.rs similarity index 100% rename from src/docs/examples/mod.rs rename to backon/src/docs/examples/mod.rs diff --git a/src/docs/examples/sqlx.md b/backon/src/docs/examples/sqlx.md similarity index 100% rename from src/docs/examples/sqlx.md rename to backon/src/docs/examples/sqlx.md diff --git a/src/docs/examples/with_args.md b/backon/src/docs/examples/with_args.md similarity index 100% rename from src/docs/examples/with_args.md rename to backon/src/docs/examples/with_args.md diff --git a/src/docs/examples/with_mut_self.md b/backon/src/docs/examples/with_mut_self.md similarity index 100% rename from src/docs/examples/with_mut_self.md rename to backon/src/docs/examples/with_mut_self.md diff --git a/src/docs/examples/with_self.md b/backon/src/docs/examples/with_self.md similarity index 100% rename from src/docs/examples/with_self.md rename to backon/src/docs/examples/with_self.md diff --git a/src/docs/examples/with_specific_error.md b/backon/src/docs/examples/with_specific_error.md similarity index 100% rename from src/docs/examples/with_specific_error.md rename to backon/src/docs/examples/with_specific_error.md diff --git a/src/docs/mod.rs b/backon/src/docs/mod.rs similarity index 100% rename from src/docs/mod.rs rename to backon/src/docs/mod.rs diff --git a/src/lib.rs b/backon/src/lib.rs similarity index 100% rename from src/lib.rs rename to backon/src/lib.rs diff --git a/src/retry.rs b/backon/src/retry.rs similarity index 100% rename from src/retry.rs rename to backon/src/retry.rs diff --git a/src/retry_with_context.rs b/backon/src/retry_with_context.rs similarity index 100% rename from src/retry_with_context.rs rename to backon/src/retry_with_context.rs diff --git a/src/sleep.rs b/backon/src/sleep.rs similarity index 100% rename from src/sleep.rs rename to backon/src/sleep.rs