Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit a83eb92

Browse files
committed
chore: Optimize code and append auth-conf.
1 parent 667c0ed commit a83eb92

18 files changed

+174
-18
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,32 @@ https://github.com/BinChengZhao/delicate)
4040

4141
- **Reusability:** Excutor provides `restful-api` that allows user applications to maintain custom tasks.
4242

43+
44+
4345
The architecture of delicate:
4446

4547
![architecture](./doc/architecture.svg)
4648
![topology](./doc/topology.svg)
4749

50+
## Project rendering
51+
<details>
52+
<summary>Click me</summary>
53+
54+
![](./doc/_media/dashboard.jpg)
55+
![](./doc/_media/executor_create.jpg)
56+
![](./doc/_media/executor_list.jpg)
57+
![](./doc/_media/group_create.jpg)
58+
![](./doc/_media/group_inner_bind.jpg)
59+
![](./doc/_media/login_en.jpg)
60+
![](./doc/_media/task_edit.jpg)
61+
![](./doc/_media/task_list_operation.jpg)
62+
![](./doc/_media/task_log_kill.jpg)
63+
![](./doc/_media/task_log_logs_2.jpg)
64+
![](./doc/_media/task_log_logs.jpg)
65+
![](./doc/_media/user_list.jpg)
66+
67+
</details>
68+
4869

4970
## Benchmark
5071
Task take about 6,424 ns (+/- 52) per scheduling on CentOS Linux release 7.6.1810 (Core) (varies by OS/hardware).

README_zhCN.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ https://github.com/BinChengZhao/delicate)
4747

4848
![topology](./doc/topology.svg)
4949

50+
51+
## 项目效果图
52+
<details>
53+
<summary>请点击</summary>
54+
55+
![](./doc/_media/dashboard.jpg)
56+
![](./doc/_media/executor_create.jpg)
57+
![](./doc/_media/executor_list.jpg)
58+
![](./doc/_media/group_create.jpg)
59+
![](./doc/_media/group_inner_bind.jpg)
60+
![](./doc/_media/login_en.jpg)
61+
![](./doc/_media/task_edit.jpg)
62+
![](./doc/_media/task_list_operation.jpg)
63+
![](./doc/_media/task_log_kill.jpg)
64+
![](./doc/_media/task_log_logs_2.jpg)
65+
![](./doc/_media/task_log_logs.jpg)
66+
![](./doc/_media/user_list.jpg)
67+
68+
</details>
69+
70+
5071
## Benchmark
5172
每次调度耗时 6,424 ns (+/- 52) 在 CentOS Linux release 7.6.1810 (Core) (不同系统/硬件会有不同的结果).
5273

delicate-executor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2018"
88

99
[dependencies]
1010
sysinfo = "^0.16.5"
11-
delay_timer = {version = "^0.7.1", features = ["full"]}
11+
delay_timer = {version = "^0.8.0", features = ["full"]}
1212
actix-web = "^3.3.2"
1313
futures = "^0.3"
1414
env_logger = "^0.8"

delicate-scheduler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ casbin = {version = '2.0.5', default-features = false, features = ["incremental"
2727

2828
cached = "^0.23.0"
2929
chrono = { version = "^0.4", features = ["serde"]}
30-
delay_timer = {version = "^0.7.1", features = ["full"]}
30+
delay_timer = {version = "^0.8.0", features = ["full"]}
3131
derive_more = "^0.99.14"
3232
delicate-utils = { path = "../delicate-utils" }
3333
diesel_migrations = "^1.4.0"

delicate-scheduler/src/actions/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ pub async fn pre_update_task_sevice(
338338
let executor_host =
339339
"http://".to_string() + (processor.host.deref()) + "/api/task/update";
340340

341-
info!("Update task{} at:{}", &task_package, &executor_host);
341+
info!("Update task {} at:{}", &task_package, &executor_host);
342342
task_package
343343
.clone()
344344
.sign(Some(&processor.token))

delicate-scheduler/src/components/auth/casbin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
use crate::prelude::*;
33

44
lazy_static! {
5+
56
pub static ref CASBIN_MODEL_CONF_PATH: String = {
67
env::var("CASBIN_MODEL_CONF").expect("CASBIN_MODEL_CONF must be set")
78
};
9+
10+
11+
// TODO: Can be listened to by `hotwatch` for changes.
812
pub static ref CASBIN_POLICY_CONF_PATH: String = {
913
env::var("CASBIN_POLICY_CONF").expect("CASBIN_POLICY_CONF must be set")
1014
};
15+
1116
// Because casbin requires that the `&str` type must satisfy static.
1217
// And the String read by environment variable does not satisfy this condition after passing deref.
1318
// Two ways to solve it.
@@ -23,10 +28,12 @@ lazy_static! {
2328

2429
}
2530

31+
#[allow(dead_code)]
2632
pub(crate) async fn warm_up_auther() {
2733
AUTHER.write().await.enable_log(true);
2834
}
2935

36+
#[allow(dead_code)]
3037
pub(crate) async fn get_auther_read_guard() -> RwLockReadGuard<'static, Enforcer> {
3138
AUTHER.read().await
3239
}

delicate-scheduler/src/components/helper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub(crate) async fn handle_response<T: DeserializeOwned + Trial>(
99
.map(|response| match response {
1010
Ok(mut r) => Some(r.json::<T>()),
1111
Err(e) => {
12-
error!("{}", e);
12+
error!("SendRequestError : {}", e);
1313
None
1414
}
1515
})
@@ -25,10 +25,10 @@ pub(crate) async fn handle_response<T: DeserializeOwned + Trial>(
2525
.map(|json_result| {
2626
match json_result {
2727
Err(ref e) => {
28-
error!("{}", e);
28+
error!("Payload errors: {}", e);
2929
}
3030
Ok(ref json) if json.is_err() => {
31-
error!("{}", json.get_msg());
31+
error!("Customized error messages: {}", json.get_msg());
3232
}
3333
_ => {}
3434
}

delicate-scheduler/src/main.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![recursion_limit = "256"]
22
#![allow(clippy::expect_fun_call)]
3+
#![allow(clippy::let_and_return)]
34
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
45

56
//! delicate-scheduler.
@@ -78,17 +79,7 @@ async fn main() -> AnyResut<()> {
7879
.wrap(components::session::auth_middleware())
7980
.wrap(components::session::session_middleware())
8081
.wrap(cors)
81-
.wrap(MiddlewareLogger::default())
82-
.wrap_fn(|req, srv| {
83-
let log_id = uuid::Uuid::new_v4().to_string();
84-
let _span_ = span!(Level::INFO, "", log_id = &*log_id).entered();
85-
86-
let fut = srv.call(req);
87-
async {
88-
let res = fut.await?;
89-
Ok(res)
90-
}
91-
});
82+
.wrap(MiddlewareLogger::default());
9283

9384
#[cfg(AUTH_CASBIN)]
9485
let app = app.wrap(CasbinService);

delicate-scheduler/src/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(unused_imports)]
12
pub(crate) use super::components::auth::casbin::*;
23
pub(crate) use super::components::base::{SchedulerMetaInfo, SharedSchedulerMetaInfo};
34
pub(crate) use super::components::health_checker::loop_health_check;

delicate-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sysinfo = "^0.16.5"
2323
derive_more = "^0.99.14"
2424
hex = {version = "^0.4", features = ["serde"]}
2525
serde = { version = "^1.0", features = ["derive"] }
26-
delay_timer = {version = "^0.7.1", features = ["full"]}
26+
delay_timer = {version = "^0.8.0", features = ["full"]}
2727
rsa = { version = "^0.4.0", features = ["std", "pem" ,"serde"] }
2828
diesel = { version = "^1.4.6", features = ["postgres", "mysql", "extras", "r2d2", "chrono"] }
2929

0 commit comments

Comments
 (0)