chore: 删除多个客户端模块

移除以下未完成的客户端模块:
- C++ 客户端和 demo
- .NET 客户端和 demo
- Kotlin 客户端和 demo
- Lua 客户端和 demo
- PHP 客户端和 demo
- Ruby 客户端和 demo
- Rust 客户端和 demo

更新根目录 README.md,移除相关说明。
This commit is contained in:
2026-04-25 21:05:00 +08:00
parent 7efca9440a
commit b4b38fa0c7
36 changed files with 27 additions and 2278 deletions
-16
View File
@@ -1,16 +0,0 @@
[package]
name = "kenaito-conf"
version = "1.0.0"
edition = "2021"
authors = ["odboy <tianjun@odboy.cn>"]
description = "Kenaito Config Center Rust Client"
[dependencies]
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
md-5 = "0.10"
aes = "0.8"
cbc = "0.1"
base64 = "0.21"
-70
View File
@@ -1,70 +0,0 @@
# Kenaito Config Center Rust Client
Rust 语言的配置中心客户端 SDK。
## 依赖
- Rust 1.70+
- reqwest (HTTP 客户端)
- tokio (异步运行时)
- aes + cbc (AES 解密)
## 安装
在 `Cargo.toml` 中添加:
```toml
[dependencies]
kenaito-conf = { path = "../kenaito-conf-rust-client" }
```
## 使用
```rust
use kenaito_conf::{Config, ConfigClient};
#[tokio::main]
async fn main() {
let config = Config {
base_url: "http://localhost:8080".to_string(),
app_name: "kenaito-springboot-demo".to_string(),
env: "daily".to_string(),
version: "latest".to_string(),
sync_interval: 30,
..Default::default()
};
let client = ConfigClient::new(config);
client.on_change(|changed| {
for (k, v) in changed.iter() {
println!("config changed: {} = {}", k, v);
}
});
client.start().await.unwrap();
let value = client.get("database.host");
let all = client.get_all();
}
```
## 配置参数
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `base_url` | 配置中心地址 | 必填 |
| `app_name` | 应用名称 | 必填 |
| `env` | 环境 | `dev` |
| `version` | 配置版本 | `latest` |
| `token` | 认证令牌 | 空 |
| `sync_interval` | 同步间隔(秒) | `60` |
| `ignore_global` | 是否忽略全局配置 | `false` |
| `cache_dir` | 本地缓存目录 | `.` |
## Demo
```bash
cd kenaito-conf-rust-client-demo
cargo run
```
-140
View File
@@ -1,140 +0,0 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct Config {
pub base_url: String,
pub app_name: String,
pub env: String,
pub version: String,
pub token: String,
pub sync_interval: u64,
pub ignore_global: bool,
pub cache_dir: String,
}
impl Default for Config {
fn default() -> Self {
Self {
base_url: String::new(),
app_name: String::new(),
env: "dev".to_string(),
version: "latest".to_string(),
token: String::new(),
sync_interval: 60,
ignore_global: false,
cache_dir: ".".to_string(),
}
}
}
#[derive(Serialize, Deserialize, Debug)]
struct FetchAllRequest {
app_name: String,
env: String,
version: String,
ignore_global: bool,
token: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct FetchChangedRequest {
app_name: String,
env: String,
version: String,
last_time: i64,
ignore_global: bool,
token: String,
}
pub struct ConfigClient {
config: Config,
configs: Arc<Mutex<HashMap<String, String>>>,
last_time: Arc<Mutex<i64>>,
handlers: Arc<Mutex<Vec<Box<dyn Fn(&HashMap<String, String>) + Send + Sync>>>>,
}
impl ConfigClient {
pub fn new(config: Config) -> Self {
Self {
config,
configs: Arc::new(Mutex::new(HashMap::new())),
last_time: Arc::new(Mutex::new(0)),
handlers: Arc::new(Mutex::new(Vec::new())),
}
}
pub fn on_change<F>(&self, handler: F)
where
F: Fn(&HashMap<String, String>) + Send + Sync + 'static,
{
self.handlers.lock().unwrap().push(Box::new(handler));
}
pub fn get(&self, key: &str) -> Option<String> {
self.configs.lock().unwrap().get(key).cloned()
}
pub fn get_all(&self) -> HashMap<String, String> {
self.configs.lock().unwrap().clone()
}
pub async fn start(&self) -> Result<(), Box<dyn std::error::Error>> {
self.fetch_all().await?;
let configs = self.configs.clone();
let last_time = self.last_time.clone();
let handlers = self.handlers.clone();
let config = self.config.clone();
tokio::spawn(async move {
loop {
tokio::time::sleep(Duration::from_secs(config.sync_interval)).await;
// fetch_changed logic here
}
});
Ok(())
}
async fn fetch_all(&self) -> Result<(), Box<dyn std::error::Error>> {
let url = format!("{}/api/fetchAllConfigs", self.config.base_url);
let client = reqwest::Client::new();
let payload = serde_json::json!({
"appName": self.config.app_name,
"env": self.config.env,
"version": self.config.version,
"ignoreGlobal": self.config.ignore_global,
"token": self.config.token,
});
let resp = client.post(&url).json(&payload).send().await?;
let data: HashMap<String, serde_json::Value> = resp.json().await?;
if let Some(code) = data.get("code") {
if code.as_i64() != Some(0) {
return Err("server error".into());
}
}
if let Some(ts) = data.get("latest.fetch.timestamp") {
*self.last_time.lock().unwrap() = ts.as_i64().unwrap_or(0);
}
let mut configs = self.configs.lock().unwrap();
for (k, v) in data.iter() {
if k.starts_with("kenaito.") || k == "latest.fetch.timestamp" {
continue;
}
if let Some(s) = v.as_str() {
configs.insert(k.clone(), s.to_string());
}
}
Ok(())
}
}