feat: use faster counter impl
This commit is contained in:
parent
45a49288b7
commit
20296d5a70
4 changed files with 411 additions and 459 deletions
806
Cargo.lock
generated
806
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
12
Cargo.toml
12
Cargo.toml
|
@ -13,8 +13,8 @@ openraft = { version = "0.8.8", features = ["serde", "single-term-leader"]}
|
|||
#libmcaptcha = { path="/src/atm/code/mcaptcha/libmcaptcha", features=["full"] }
|
||||
libmcaptcha = { git = "https://github.com/mcaptcha/libmcaptcha", branch = "feat-dcache", features = ["full"]}
|
||||
tracing = { version = "0.1.37", features = ["log"] }
|
||||
serde_json = "1.0.96"
|
||||
serde = { version = "1.0.163", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
byteorder = "1.4.3"
|
||||
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
@ -26,7 +26,7 @@ derive_more = "0.99.17"
|
|||
url = { version = "2.2.2", features = ["serde"]}
|
||||
async-trait = "0.1.36"
|
||||
clap = { version = "4.1.11", features = ["derive", "env"] }
|
||||
tokio = { version = "1.0", default-features = false, features = ["sync", "macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.0", default-features = false, features = ["sync", "macros", "rt-multi-thread", "time"] }
|
||||
tracing-subscriber = { version = "0.3.0", features = ["env-filter"] }
|
||||
actix = "0.13.0"
|
||||
tonic = { version = "0.10.2", features = ["transport", "channel"] }
|
||||
|
@ -34,6 +34,9 @@ prost = "0.12.3"
|
|||
tokio-stream = "0.1.14"
|
||||
async-stream = "0.3.5"
|
||||
actix-rt = "2.9.0"
|
||||
futures = "0.3.30"
|
||||
tower-service = "0.3.2"
|
||||
dashmap = { version = "5.5.3", features = ["serde"] }
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -44,3 +47,6 @@ tonic-build = "0.10.2"
|
|||
base64 = "0.13.0"
|
||||
anyhow = "1.0.63"
|
||||
maplit = "1.0.2"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
|
|
@ -36,7 +36,9 @@ use crate::store::DcacheResponse;
|
|||
use crate::store::DcacheStore;
|
||||
|
||||
pub mod app;
|
||||
mod mcaptcha;
|
||||
pub mod network;
|
||||
mod pool;
|
||||
mod protobuf;
|
||||
pub mod store;
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ pub struct DcacheStateMachine {
|
|||
|
||||
/// Application data.
|
||||
pub data: Arc<System<HashCache, EmbeddedMaster>>,
|
||||
pub new_data: crate::mcaptcha::mcaptcha::Manager,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
@ -129,16 +130,13 @@ impl PersistableStateMachine {
|
|||
self,
|
||||
data: Arc<System<HashCache, EmbeddedMaster>>,
|
||||
) -> DcacheStateMachine {
|
||||
data.master
|
||||
.send(SetInternalData {
|
||||
mcaptcha: self.data,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let new_data = crate::mcaptcha::mcaptcha::Manager::new(30);
|
||||
new_data.set_internal_data(self.data.clone());
|
||||
DcacheStateMachine {
|
||||
last_applied_log: self.last_applied_log,
|
||||
last_membership: self.last_membership,
|
||||
data,
|
||||
new_data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +164,7 @@ impl DcacheStore {
|
|||
last_applied_log: Default::default(),
|
||||
last_membership: Default::default(),
|
||||
data: system::init_system(salt),
|
||||
new_data: crate::mcaptcha::mcaptcha::Manager::new(30),
|
||||
});
|
||||
|
||||
Self {
|
||||
|
@ -391,49 +390,22 @@ impl RaftStorage<DcacheTypeConfig> for Arc<DcacheStore> {
|
|||
EntryPayload::Blank => res.push(DcacheResponse::Empty),
|
||||
EntryPayload::Normal(ref req) => match req {
|
||||
DcacheRequest::AddVisitor(msg) => {
|
||||
let r = sm
|
||||
.data
|
||||
.master
|
||||
.send(msg.clone())
|
||||
.await
|
||||
.unwrap()
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let r = sm.new_data.add_visitor(msg);
|
||||
|
||||
|
||||
res.push(DcacheResponse::AddVisitorResult(r));
|
||||
}
|
||||
DcacheRequest::AddCaptcha(msg) => {
|
||||
sm.data
|
||||
.master
|
||||
.send(msg.clone())
|
||||
.await
|
||||
.unwrap()
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
sm.new_data
|
||||
.add_captcha(Arc::new((&msg.mcaptcha).into()), msg.id.clone());
|
||||
res.push(DcacheResponse::Empty);
|
||||
}
|
||||
DcacheRequest::RenameCaptcha(msg) => {
|
||||
sm.data
|
||||
.master
|
||||
.send(msg.clone())
|
||||
.await
|
||||
.unwrap()
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
sm.new_data.rename(&msg.name, msg.rename_to.clone());
|
||||
res.push(DcacheResponse::Empty);
|
||||
}
|
||||
DcacheRequest::RemoveCaptcha(msg) => {
|
||||
sm.data
|
||||
.master
|
||||
.send(msg.clone())
|
||||
.await
|
||||
.unwrap()
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
sm.new_data.rm_captcha(&msg.0);
|
||||
res.push(DcacheResponse::Empty);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue