diff --git a/Cargo.toml b/Cargo.toml index 6741d8f..0f2b123 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,19 +11,53 @@ rust-version = "1.62" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +blocking = ["diesel", "diesel-derive-enum", "dotenv"] +asynk = ["bb8-postgres", "postgres-types", "tokio", "async-trait", "typed-builder"] + [dependencies] -diesel = { version = "1.4", features = ["postgres", "serde_json", "chrono", "uuidv07", "r2d2"] } -diesel-derive-enum = { version = "1", features = ["postgres"] } -dotenv = "0.15" -uuid = { version = "0.8", features = ["v4"] } chrono = "0.4" -serde_json = "1" -typetag = "0.2" log = "0.4" serde = { version = "1", features = ["derive"] } +serde_json = "1" thiserror = "1.0" -bb8-postgres = {version = "0.8", features = ["with-serde_json-1" , "with-uuid-0_8" , "with-chrono-0_4" ]} -postgres-types = { version = "0.X.X", features = ["derive"] } -tokio = { version = "1.20", features = ["full"] } -async-trait = "0.1" -typed-builder = "0.10" +typetag = "0.2" +uuid = { version = "0.8", features = ["v4"] } + + +[dependencies.diesel] +version = "1.4" +features = ["postgres", "serde_json", "chrono", "uuidv07", "r2d2"] +optional = true + +[dependencies.diesel-derive-enum] +version = "1" +features = ["postgres"] +optional = true + +[dependencies.dotenv] +version = "0.15" +optional = true + +[dependencies.bb8-postgres] +version = "0.8" +features = ["with-serde_json-1" , "with-uuid-0_8" , "with-chrono-0_4"] +optional = true + +[dependencies.postgres-types] +version = "0.X.X" +features = ["derive"] +optional = true + +[dependencies.tokio] +version = "1.20" +features = ["full"] +optional = true + +[dependencies.async-trait] +version = "0.1" +optional = true + +[dependencies.typed-builder] +version = "0.10" +optional = true diff --git a/fang_examples/simple_worker/Cargo.toml b/fang_examples/simple_worker/Cargo.toml index f1c3328..287c552 100644 --- a/fang_examples/simple_worker/Cargo.toml +++ b/fang_examples/simple_worker/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -fang = { path = "../../" } +fang = { path = "../../" , features = ["blocking"]} serde = { version = "1.0", features = ["derive"] } signal-hook = "0.3.10" dotenv = "0.15.0" diff --git a/src/sync/error.rs b/src/blocking/error.rs similarity index 100% rename from src/sync/error.rs rename to src/blocking/error.rs diff --git a/src/sync/executor.rs b/src/blocking/executor.rs similarity index 100% rename from src/sync/executor.rs rename to src/blocking/executor.rs diff --git a/src/sync/mod.rs b/src/blocking/mod.rs similarity index 100% rename from src/sync/mod.rs rename to src/blocking/mod.rs diff --git a/src/sync/queue.rs b/src/blocking/queue.rs similarity index 100% rename from src/sync/queue.rs rename to src/blocking/queue.rs diff --git a/src/sync/scheduler.rs b/src/blocking/scheduler.rs similarity index 100% rename from src/sync/scheduler.rs rename to src/blocking/scheduler.rs diff --git a/src/sync/schema.rs b/src/blocking/schema.rs similarity index 100% rename from src/sync/schema.rs rename to src/blocking/schema.rs diff --git a/src/sync/worker_pool.rs b/src/blocking/worker_pool.rs similarity index 100% rename from src/sync/worker_pool.rs rename to src/blocking/worker_pool.rs diff --git a/src/lib.rs b/src/lib.rs index a6d3bf1..cf12c64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,29 +1,20 @@ -// #![allow(clippy::nonstandard_macro_braces)] #![allow(clippy::extra_unused_lifetimes)] -// pub mod error; -// pub mod executor; -// pub mod queue; -// pub mod scheduler; -// pub mod schema; -// pub mod worker_pool; - -// pub use error::FangError; -// pub use executor::*; -// pub use queue::*; -// pub use scheduler::*; -// pub use schema::*; -// pub use worker_pool::*; - #[macro_use] +#[cfg(feature = "blocking")] extern crate diesel; #[doc(hidden)] +#[cfg(feature = "blocking")] pub use diesel::pg::PgConnection; + #[doc(hidden)] pub use typetag; -pub mod sync; -pub use sync::*; +#[cfg(feature = "blocking")] +pub mod blocking; +#[cfg(feature = "blocking")] +pub use blocking::*; +#[cfg(feature = "asynk")] pub mod asynk;