diff --git a/Cargo.lock b/Cargo.lock index 68cf4a2..495f4e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,9 +230,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -260,18 +260,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", @@ -761,9 +761,9 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -1615,9 +1615,9 @@ checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "20b9b67e2ca7dd9e9f9285b759de30ff538aab981abaaf7bc9bd90b84a0126c3" dependencies = [ "base64", "bytes", @@ -1651,7 +1651,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.22.6", + "webpki-roots 0.25.2", "winreg", ] @@ -1743,9 +1743,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.3" +version = "0.101.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261e9e0888cba427c3316e6322805653c9425240b6fd96cee7cb671ab70ab8d0" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring", "untrusted", @@ -1796,9 +1796,9 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" dependencies = [ "serde_derive", ] @@ -1815,9 +1815,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" dependencies = [ "proc-macro2", "quote", @@ -1917,9 +1917,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -2259,7 +2259,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "teamspeak-management-tools" -version = "4.0.2" +version = "4.0.3" dependencies = [ "anyhow", "async-trait", @@ -2357,9 +2357,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", @@ -2581,9 +2581,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicase" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" dependencies = [ "version_check", ] @@ -2761,9 +2761,9 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-streams" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" dependencies = [ "futures-util", "js-sys", @@ -2782,33 +2782,20 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" dependencies = [ - "webpki", + "rustls-webpki", ] [[package]] name = "webpki-roots" -version = "0.24.0" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" -dependencies = [ - "rustls-webpki", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "whoami" @@ -2867,9 +2854,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -2882,62 +2869,63 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.12" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83817bbecf72c73bad717ee86820ebf286203d2e04c3951f3cd538869c897364" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 1e5948a..97924ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "teamspeak-management-tools" -version = "4.0.2" +version = "4.0.3" edition = "2021" [dependencies] @@ -15,7 +15,7 @@ kstool = "0.2.1" log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] } once_cell = "^1.10" redis = { version = "0.23", features = ["tokio-comp"] } -rusty-leveldb = { version = "2.0.0", features = ["async"] } +rusty-leveldb = { version = "2.0.0", features = ["async"], optional = true } serde = "1" serde-teamspeak-querystring = "0.2.1" serde_derive = "1" @@ -36,5 +36,6 @@ panic = "abort" [features] default = [] -all = ["tracker"] +all = ["tracker", "leveldb"] tracker = ["sqlx"] +leveldb = ["rusty-leveldb"] diff --git a/src/auto_channel.rs b/src/auto_channel.rs index 39b1d1a..52bcacb 100644 --- a/src/auto_channel.rs +++ b/src/auto_channel.rs @@ -7,7 +7,6 @@ use crate::socketlib::SocketConn; use crate::{AUTO_CHANNEL_NICKNAME_OVERRIDE, DEFAULT_AUTO_CHANNEL_NICKNAME}; use anyhow::anyhow; use log::{debug, error, info, trace, warn}; -use redis::AsyncCommands; use std::time::Duration; use tap::{Tap, TapFallible}; use tokio::sync::mpsc; @@ -138,12 +137,11 @@ pub async fn auto_channel_staff( config: Config, thread_id: String, ) -> anyhow::Result<()> { - let redis = redis::Client::open(config.server().redis_server()) - .map_err(|e| anyhow!("Connect redis server error! {:?}", e))?; - let mut redis_conn = redis - .get_async_connection() + let mut kv_map = config + .server() + .get_kv_map() .await - .map_err(|e| anyhow!("Get redis connection error: {:?}", e))?; + .map_err(|e| anyhow!("Got error while create KV map: {:?}", e))?; let monitor_channels = config.server().channels(); let privilege_group = config.server().privilege_group_id(); @@ -192,8 +190,8 @@ pub async fn auto_channel_staff( *channel_id, ); - redis_conn - .del::<_, i64>(&key) + kv_map + .delete(&key) .await .tap(|_| trace!("[{}] Deleted", thread_id)) .tap_err(|e| { @@ -257,7 +255,14 @@ pub async fn auto_channel_staff( pid = client.channel_id() ); - let ret: Option = redis_conn.get(&key).await?; + let ret: Option = kv_map + .get(&key) + .await? + .map(|v| v.parse()) + .transpose() + .tap_err(|e| error!("[{}] Unable to parse result: {:?}", thread_id, e)) + .ok() + .flatten(); let create_new = ret.is_none(); let target_channel = if create_new { let mut name = format!("{}'s channel", client.client_nickname()); @@ -326,7 +331,7 @@ pub async fn auto_channel_staff( Ok(ret) => ret, Err(e) => { if e.code() == 768 { - redis_conn.del(&key).await?; + kv_map.delete(&key).await?; skip_sleep = true; continue; } @@ -348,7 +353,7 @@ pub async fn auto_channel_staff( conn.move_client(who_am_i.client_id(), client.channel_id()) .await .map_err(|e| anyhow!("Unable move self out of channel. {:?}", e))?; - redis_conn.set(&key, target_channel).await?; + kv_map.set(&key, target_channel).await?; } info!("Move {} to {}", client.client_nickname(), target_channel); diff --git a/src/configure.rs b/src/configure.rs index bc3c8ca..1dbd84e 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -1,6 +1,5 @@ pub mod config { use crate::plugins::kv::current::KVMap; - use crate::DEFAULT_LEVELDB_LOCATION; use anyhow::anyhow; use serde_derive::Deserialize; use std::collections::HashMap; @@ -78,6 +77,7 @@ pub mod config { channel_id: Numbers, privilege_group_id: i64, redis_server: Option, + #[cfg(feature = "leveldb")] leveldb: Option, ignore_user: Option>, whitelist_ip: Option>, @@ -98,8 +98,6 @@ pub mod config { self.privilege_group_id } - #[deprecated] - #[allow(unused)] pub fn redis_server(&self) -> String { if let Some(server) = &self.redis_server { server.clone() @@ -108,6 +106,7 @@ pub mod config { } } + #[cfg(feature = "leveldb")] pub async fn get_kv_map(&self) -> anyhow::Result { if let Some(redis) = &self.redis_server { return KVMap::new_redis(redis).await; @@ -116,11 +115,16 @@ pub mod config { KVMap::new_leveldb(if let Some(db) = &self.leveldb { db } else { - DEFAULT_LEVELDB_LOCATION + crate::DEFAULT_LEVELDB_LOCATION; }) .await } + #[cfg(not(feature = "leveldb"))] + pub async fn get_kv_map(&self) -> anyhow::Result { + KVMap::new_redis(&self.redis_server()).await + } + pub fn ignore_user_name(&self) -> Vec { self.ignore_user.clone().unwrap_or_default() } diff --git a/src/main.rs b/src/main.rs index 135b70a..5724e23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ use tokio::sync::Notify; const DEFAULT_OBSERVER_NICKNAME: &str = "observer"; const DEFAULT_AUTO_CHANNEL_NICKNAME: &str = "auto channel"; +#[cfg(feature = "leveldb")] const DEFAULT_LEVELDB_LOCATION: &str = "./level.db"; pub static OBSERVER_NICKNAME_OVERRIDE: OnceCell = OnceCell::new(); diff --git a/src/plugins/kv.rs b/src/plugins/kv.rs index b1a9f38..5640cb4 100644 --- a/src/plugins/kv.rs +++ b/src/plugins/kv.rs @@ -4,7 +4,6 @@ pub mod v1 { use std::fmt::Display; enum KVTypes { - LevelDB(rusty_leveldb::AsyncDB), Redis(redis::aio::Connection), } @@ -15,40 +14,21 @@ pub mod v1 { impl KVMap { pub async fn new_redis(redis_server: &str) -> anyhow::Result { let redis = redis::Client::open(redis_server) - .map_err(|e| anyhow!("Connect redis server error! {:?}", e))?; - let redis_conn = redis + .map_err(|e| anyhow!("Connect redis server error! {:?}", e))? .get_async_connection() .await .map_err(|e| anyhow!("Get redis connection error: {:?}", e))?; Ok(Self { - inner: KVTypes::Redis(redis_conn), + inner: KVTypes::Redis(redis), }) } - pub async fn new_leveldb(level_db: &str) -> anyhow::Result { - Self::new_leveldb_with_option(level_db, rusty_leveldb::Options::default()).await - } - - pub(super) async fn new_leveldb_with_option( - level_db: &str, - options: rusty_leveldb::Options, - ) -> anyhow::Result { - let level_db = rusty_leveldb::AsyncDB::new(level_db, options) - .map_err(|e| anyhow!("Connect to leveldb error: {:?}", e))?; - Ok(Self { - inner: KVTypes::LevelDB(level_db), - }) - } - - pub async fn set(&mut self, k: D, v: D) -> anyhow::Result<()> { + pub async fn set( + &mut self, + k: D, + v: V, + ) -> anyhow::Result<()> { match self.inner { - KVTypes::LevelDB(ref mut db) => { - db.put( - k.to_string().as_bytes().to_vec(), - v.to_string().as_bytes().to_vec(), - ) - .await?; - } KVTypes::Redis(ref mut redis) => { redis.set(k.to_string(), v.to_string()).await?; } @@ -58,9 +38,6 @@ pub mod v1 { pub async fn delete(&mut self, k: D) -> anyhow::Result<()> { match self.inner { - KVTypes::LevelDB(ref mut db) => { - db.delete(k.to_string().as_bytes().to_vec()).await?; - } KVTypes::Redis(ref mut redis) => { redis.del(k.to_string()).await?; } @@ -73,42 +50,12 @@ pub mod v1 { k: D, ) -> anyhow::Result> { Ok(match self.inner { - KVTypes::LevelDB(ref mut db) => db - .get(k.to_string().as_bytes().to_vec()) - .await? - .map(String::from_utf8) - .transpose()?, KVTypes::Redis(ref mut redis) => { redis.get::<_, Option>(k.to_string()).await? } }) } } - - #[cfg(test)] - mod test { - use super::*; - - async fn async_test() -> anyhow::Result<()> { - let mut db = - KVMap::new_leveldb_with_option("db.tmp", rusty_leveldb::in_memory()).await?; - db.set("A", "114514").await?; - assert_eq!(db.get("A").await?, Some("114514".to_string())); - db.delete("A").await?; - assert_eq!(db.get("A").await?, None); - Ok(()) - } - - #[test] - fn test() { - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap() - .block_on(async_test()) - .unwrap() - } - } } pub use v1 as current; diff --git a/src/plugins/kv_ng.rs b/src/plugins/kv_ng.rs new file mode 100644 index 0000000..9f9f445 --- /dev/null +++ b/src/plugins/kv_ng.rs @@ -0,0 +1,124 @@ +pub mod v1 { + use anyhow::anyhow; + use redis::AsyncCommands; + use std::fmt::Display; + use std::sync::Arc; + use tokio::sync::Mutex; + + enum KVTypes { + LevelDB(Arc>), + Redis(redis::aio::Connection), + } + + pub struct KVMap { + inner: KVTypes, + } + + impl KVMap { + pub async fn new_redis(redis_server: &str) -> anyhow::Result { + let redis = redis::Client::open(redis_server) + .map_err(|e| anyhow!("Connect redis server error! {:?}", e))?; + let redis_conn = redis + .get_async_connection() + .await + .map_err(|e| anyhow!("Get redis connection error: {:?}", e))?; + Ok(Self { + inner: KVTypes::Redis(redis_conn), + }) + } + + pub async fn new_leveldb(level_db: &str) -> anyhow::Result { + Self::new_leveldb_with_option(level_db, rusty_leveldb::Options::default()).await + } + + pub(super) async fn new_leveldb_with_option( + level_db: &str, + options: rusty_leveldb::Options, + ) -> anyhow::Result { + let level_db = rusty_leveldb::AsyncDB::new(level_db, options) + .map_err(|e| anyhow!("Connect to leveldb error: {:?}", e))?; + Ok(Self { + inner: KVTypes::LevelDB(Arc::new(Mutex::new(level_db))), + }) + } + + pub async fn set( + &mut self, + k: D, + v: V, + ) -> anyhow::Result<()> { + match self.inner { + KVTypes::LevelDB(ref mut db) => { + let db = db.lock().await; + db.put( + k.to_string().as_bytes().to_vec(), + v.to_string().as_bytes().to_vec(), + ) + .await?; + } + KVTypes::Redis(ref mut redis) => { + redis.set(k.to_string(), v.to_string()).await?; + } + } + Ok(()) + } + + pub async fn delete(&mut self, k: D) -> anyhow::Result<()> { + match self.inner { + KVTypes::LevelDB(ref mut db) => { + let db = db.lock().await; + db.delete(k.to_string().as_bytes().to_vec()).await?; + } + KVTypes::Redis(ref mut redis) => { + redis.del(k.to_string()).await?; + } + } + Ok(()) + } + + pub async fn get( + &mut self, + k: D, + ) -> anyhow::Result> { + Ok(match self.inner { + KVTypes::LevelDB(ref mut db) => { + let db = db.lock().await; + db.get(k.to_string().as_bytes().to_vec()) + .await? + .map(String::from_utf8) + .transpose()? + } + KVTypes::Redis(ref mut redis) => { + redis.get::<_, Option>(k.to_string()).await? + } + }) + } + } + + #[cfg(test)] + mod test { + use super::*; + + async fn async_test() -> anyhow::Result<()> { + let mut db = + KVMap::new_leveldb_with_option("db.tmp", rusty_leveldb::in_memory()).await?; + db.set("A", "114514").await?; + assert_eq!(db.get("A").await?, Some("114514".to_string())); + db.delete("A").await?; + assert_eq!(db.get("A").await?, None); + Ok(()) + } + + #[test] + fn test() { + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() + .block_on(async_test()) + .unwrap() + } + } +} + +pub use v1 as current; diff --git a/src/plugins/mod.rs b/src/plugins/mod.rs index 4ad4fbb..4697578 100644 --- a/src/plugins/mod.rs +++ b/src/plugins/mod.rs @@ -1,3 +1,10 @@ +#[cfg(not(feature = "leveldb"))] pub mod kv; #[cfg(feature = "tracker")] pub mod tracker; + +#[cfg(feature = "leveldb")] +pub mod kv_ng; + +#[cfg(feature = "leveldb")] +pub use kv_ng as kv;