diff --git a/Cargo.lock b/Cargo.lock index 29e87ab15ed20ec0c33d1ac0a0c5b3387bd5d220..262031b036dc8c4781a718416bd765d1861ac7b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -903,6 +903,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "flume" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9e818efa7776f4dd7df0e542f877f7a5a87bddd6a1a10f59a7732b71ffb9d55" +dependencies = [ + "futures-core", + "futures-sink", + "rand 0.7.3", + "spinning_top", +] + [[package]] name = "fragile" version = "1.0.0" @@ -967,6 +979,12 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-sink" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8764258ed64ebc5d9ed185cf86a95db5cac810269c5d20ececb32e0088abbd" + [[package]] name = "fxhash" version = "0.2.1" @@ -1129,10 +1147,9 @@ dependencies = [ name = "kv_typed" version = "0.1.0" dependencies = [ - "async-channel", "async-std", "criterion", - "crossbeam-channel", + "flume", "kv_typed_code_gen", "leveldb_minimal", "maybe-async", @@ -1655,6 +1672,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ppv-lite86" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" + [[package]] name = "predicates" version = "1.0.5" @@ -1739,6 +1762,29 @@ dependencies = [ "winapi", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1754,6 +1800,24 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "rayon" version = "1.4.1" @@ -2075,6 +2139,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spinning_top" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e529d73e80d64b5f2631f9035113347c578a1c9c7774b83a2b880788459ab36" +dependencies = [ + "lock_api 0.4.1", +] + [[package]] name = "strsim" version = "0.8.0" @@ -2152,7 +2225,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" dependencies = [ - "rand", + "rand 0.4.6", "remove_dir_all", ] diff --git a/rust-libs/tools/kv_typed/Cargo.toml b/rust-libs/tools/kv_typed/Cargo.toml index 918df5bd97f43d61847918711349df79e44d1d05..c3823e16425c566c0e511dd7d35fb8b9ab90b75a 100644 --- a/rust-libs/tools/kv_typed/Cargo.toml +++ b/rust-libs/tools/kv_typed/Cargo.toml @@ -12,8 +12,7 @@ edition = "2018" path = "src/lib.rs" [dependencies] -async-channel = { version = "1.4.2", optional = true } -crossbeam-channel = { version = "0.4.4", optional = true } +flume = "0.9.1" kv_typed_code_gen = { path = "../kv_typed_code_gen" } leveldb_minimal = { version = "0.1.0", optional = true } mockall = { version = "0.8.0", optional = true } @@ -43,13 +42,13 @@ criterion = { version = "0.3.1" } [features] default = ["memory_backend"] -async = ["async-channel"] +async = [] explorer = ["rayon", "regex", "serde_json"] leveldb_backend = ["leveldb_minimal"] memory_backend = ["parking_lot"] sled_backend = ["sled"] subscription = ["parking_lot"] -sync = ["crossbeam-channel"] +sync = [] mock = ["mockall"] diff --git a/rust-libs/tools/kv_typed/src/lib.rs b/rust-libs/tools/kv_typed/src/lib.rs index 51c8f105f608a067634573b9d42390620c06eaa5..c8d96d2b9d50f14323ac7fbe01e6f62b9fbd303c 100644 --- a/rust-libs/tools/kv_typed/src/lib.rs +++ b/rust-libs/tools/kv_typed/src/lib.rs @@ -44,10 +44,7 @@ mod utils; mod value; // Re-export dependencies -#[cfg(feature = "async")] -pub use async_channel as channel; -#[cfg(all(not(feature = "async"), feature = "sync"))] -pub use crossbeam_channel as channel; +pub use flume as channel; #[cfg(feature = "explorer")] pub use regex; pub use zerocopy; @@ -98,11 +95,7 @@ pub(crate) use crate::prelude::*; pub(crate) use crate::subscription::ColSubscribers; pub(crate) use crate::utils::arc::Arc; pub(crate) use crate::utils::ivec::IVec; -#[cfg(feature = "async")] -use async_channel::{unbounded, Receiver, Sender, TrySendError}; -#[cfg(all(not(feature = "async"), feature = "sync"))] -#[allow(unused_imports)] -use crossbeam_channel::{unbounded, Receiver, Sender, TrySendError}; +use flume::{unbounded, Receiver, Sender, TrySendError}; pub(crate) use smallvec::SmallVec; pub(crate) use std::{ collections::{BTreeSet, HashSet}, diff --git a/rust-libs/tools/kv_typed/tests/db_schema.rs b/rust-libs/tools/kv_typed/tests/db_schema.rs index 8c8d156195699cea29182544847fe8f5f2be832e..c1998fa286f77b5f4adbf6b9f933b55a61abbae6 100644 --- a/rust-libs/tools/kv_typed/tests/db_schema.rs +++ b/rust-libs/tools/kv_typed/tests/db_schema.rs @@ -32,8 +32,9 @@ mod tests { ] ); - #[maybe_async::test(not(feature = "async"), async(feature = "async", async_std::test))] - async fn test_db_schema() -> KvResult<()> { + //#[maybe_async::test(not(feature = "async"), async(feature = "async", async_std::test))] + #[test] + fn test_db_schema() -> KvResult<()> { let db = TestV1Db::<Mem>::open(MemConf::default())?; #[cfg(feature = "subscription")] @@ -53,7 +54,7 @@ mod tests { value: "toto".to_owned(), }]; #[allow(unused_parens)] - if let Ok(msg) = recv.recv().await { + if let Ok(msg) = recv.recv() { assert_eq!(msg.as_ref(), &expected_events,) } else { panic!("must be receive event")