mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: update logging types and clean up ProxyRequestCache usage
This commit is contained in:
@@ -24,8 +24,7 @@ fn create_error(msg: impl Into<String>) -> AnyError {
|
||||
}
|
||||
|
||||
pub struct IpcManager {
|
||||
ipc_path: String,
|
||||
config: ClientConfig,
|
||||
client: IpcHttpClient,
|
||||
}
|
||||
|
||||
impl IpcManager {
|
||||
@@ -41,25 +40,25 @@ impl IpcManager {
|
||||
std::path::PathBuf::from("/tmp/clash-verge-ipc") // fallback path
|
||||
});
|
||||
let ipc_path = ipc_path_buf.to_str().unwrap_or_default();
|
||||
Self {
|
||||
ipc_path: ipc_path.to_string(),
|
||||
config: ClientConfig {
|
||||
default_timeout: Duration::from_secs(5),
|
||||
enable_pooling: true,
|
||||
let config = ClientConfig {
|
||||
default_timeout: Duration::from_secs(5),
|
||||
enable_pooling: true,
|
||||
max_retries: 3,
|
||||
max_concurrent_requests: 64,
|
||||
max_requests_per_second: Some(10.0),
|
||||
pool_config: PoolConfig {
|
||||
max_size: 64,
|
||||
min_idle: 8,
|
||||
max_idle_time_ms: 60_000,
|
||||
max_retries: 3,
|
||||
max_concurrent_requests: 32,
|
||||
max_requests_per_second: Some(5.0),
|
||||
pool_config: PoolConfig {
|
||||
max_size: 32,
|
||||
min_idle: 2,
|
||||
max_idle_time_ms: 10_000,
|
||||
max_retries: 3,
|
||||
max_concurrent_requests: 32,
|
||||
max_requests_per_second: Some(5.0),
|
||||
..Default::default()
|
||||
},
|
||||
max_concurrent_requests: 64,
|
||||
max_requests_per_second: Some(10.0),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
Self {
|
||||
client: IpcHttpClient::with_config(ipc_path, config).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,8 +73,7 @@ impl IpcManager {
|
||||
path: &str,
|
||||
body: Option<&serde_json::Value>,
|
||||
) -> AnyResult<LegacyResponse> {
|
||||
let client = IpcHttpClient::with_config(&self.ipc_path, self.config.clone())?;
|
||||
client.request(method, path, body).await
|
||||
self.client.request(method, path, body).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::{
|
||||
core::{handle, timer::Timer, tray::Tray},
|
||||
log_err, logging,
|
||||
process::AsyncHandler,
|
||||
state::proxy::ProxyRequestCache,
|
||||
utils::{logging::Type, window_manager::WindowManager},
|
||||
};
|
||||
|
||||
@@ -153,6 +154,7 @@ pub async fn entry_lightweight_mode() {
|
||||
}
|
||||
set_lightweight_mode(true).await;
|
||||
let _ = cancel_light_weight_timer();
|
||||
ProxyRequestCache::global().clean_default_keys();
|
||||
|
||||
// 更新托盘显示
|
||||
logging_error!(Type::Lightweight, true, Tray::global().update_part().await);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// use crate::utils::logging::Type;
|
||||
// use crate::{logging, singleton};
|
||||
use crate::singleton;
|
||||
use dashmap::DashMap;
|
||||
use serde_json::Value;
|
||||
@@ -78,6 +80,22 @@ impl ProxyRequestCache {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
pub fn clean_default_keys(&self) {
|
||||
// logging!(info, Type::Cache, "Cleaning proxies keys");
|
||||
// let proxies_key = Self::make_key("proxies", "default");
|
||||
// self.map.remove(&proxies_key);
|
||||
|
||||
// logging!(info, Type::Cache, "Cleaning providers keys");
|
||||
// let providers_key = Self::make_key("providers", "default");
|
||||
// self.map.remove(&providers_key);
|
||||
|
||||
// !The frontend goes crash if we clean the clash_config cache
|
||||
// logging!(info, Type::Cache, "Cleaning clash config keys");
|
||||
// let clash_config_key = Self::make_key("clash_config", "default");
|
||||
// self.map.remove(&clash_config_key);
|
||||
}
|
||||
}
|
||||
|
||||
// Use singleton macro
|
||||
|
||||
@@ -18,6 +18,7 @@ pub enum Type {
|
||||
Network,
|
||||
ProxyMode,
|
||||
Ipc,
|
||||
// Cache,
|
||||
}
|
||||
|
||||
impl fmt::Display for Type {
|
||||
@@ -39,6 +40,7 @@ impl fmt::Display for Type {
|
||||
Type::Network => write!(f, "[Network]"),
|
||||
Type::ProxyMode => write!(f, "[ProxMode]"),
|
||||
Type::Ipc => write!(f, "[IPC]"),
|
||||
// Type::Cache => write!(f, "[Cache]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user