Skip to content

Commit

Permalink
1. 控制台前端版本切回v0.3.12,新版本问题全部处理好后再切回新版
Browse files Browse the repository at this point in the history
2. 兼容nacos instance beat接口的两种模式 #85
3. 更新r-nacos版本到v0.5.10
  • Loading branch information
heqingpan committed May 27, 2024
1 parent f8b4303 commit 9f376d8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.5.9

2024-05-21

1. ✨新增: 调整github workflows以增加支持打包MacOS arm64安装包 #77
2. ✨新增: 面向SDK的接口增加鉴权 #65
3. ✨新增: 支持开启集群间的通信请求校验cluster token #93
4. 🛠️优化: 切换重构后的新版控制台目前功能基本一致;后续会基于新版适配支持移动端,支持国际化等。#58
5. 🛠️优化: openapi接口代码结构调整重构 #62

## v0.5.7

2024-05-05
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rnacos"
version = "0.5.9"
version = "0.5.10"
authors = ["heqingpan <heqingpan@126.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down Expand Up @@ -56,7 +56,7 @@ mime_guess = { version = "2" }
rusqlite = { version = "0.25", features = ["bundled"] }
rsql_builder = "0.1.5"
inner-mem-cache = "0.1.6"
rnacos-web-dist-wrap = "=0.4.1"
rnacos-web-dist-wrap = "=0.3.12"
nacos_rust_client = "0.2"
zip = "0.6"
tempfile = "3"
Expand Down
2 changes: 1 addition & 1 deletion src/common/constant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

pub const APP_VERSION: &str = "0.5.9";
pub const APP_VERSION: &str = "0.5.10";

pub const EMPTY_STR: &str = "";

Expand Down
74 changes: 65 additions & 9 deletions src/openapi/naming/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ pub struct BeatRequest {
pub group_name: Option<String>,
pub ephemeral: Option<String>,
pub beat: Option<String>,
pub ip: Option<String>,
pub port: Option<u32>,
}

impl BeatRequest {
Expand All @@ -200,11 +202,19 @@ impl BeatRequest {
group_name: select_option_by_clone(&self.group_name, &o.group_name),
ephemeral: select_option_by_clone(&self.ephemeral, &o.ephemeral),
beat: select_option_by_clone(&self.beat, &o.beat),
ip: select_option_by_clone(&self.ip, &o.ip),
port: select_option_by_clone(&self.port, &o.port),
}
}

pub fn convert_to_instance(self) -> Result<Instance, String> {
let beat = self.beat.unwrap_or_default();
/*
pub fn convert_to_instance_old(self) -> Result<Instance, String> {
let beat = match self.beat {
Some(v) => v,
None => {
return Err("beat value is empty".to_string());
}
};
let beat_info = match serde_json::from_str::<BeatInfo>(&beat) {
Ok(v) => v,
Err(err) => {
Expand Down Expand Up @@ -243,6 +253,57 @@ impl BeatRequest {
instance.generate_key();
Ok(instance)
}
*/

pub fn convert_to_instance(self) -> anyhow::Result<Instance> {
let mut beat_info = self.get_beat_info()?;
let use_beat = self.beat.as_ref().map_or(false, |s| !s.is_empty());
if !use_beat {
beat_info.ip = self.ip;
beat_info.port = self.port;
}
let service_name_option = beat_info.service_name.clone();
let mut instance = beat_info.convert_to_instance();
if service_name_option.is_none() {
let grouped_name = self.service_name.unwrap();
if let Some((group_name, service_name)) =
NamingUtils::split_group_and_serivce_name(&grouped_name)
{
instance.service_name = Arc::new(service_name);
instance.group_name = Arc::new(group_name);
}
if let Some(group_name) = self.group_name.as_ref() {
if !group_name.is_empty() {
instance.group_name = Arc::new(group_name.to_owned());
}
}
}
instance.ephemeral = get_bool_from_string(&self.ephemeral, true);
instance.cluster_name = NamingUtils::default_cluster(
self.cluster_name
.as_ref()
.unwrap_or(&"".to_owned())
.to_owned(),
);
instance.namespace_id = Arc::new(NamingUtils::default_namespace(
self.namespace_id
.as_ref()
.unwrap_or(&"".to_owned())
.to_owned(),
));
instance.generate_key();
Ok(instance)
}

fn get_beat_info(&self) -> anyhow::Result<BeatInfo> {
let beat_str = self.beat.clone().unwrap_or_default();
if let Some(beat_str) = self.beat.as_ref() {
let v = serde_json::from_str::<BeatInfo>(&beat_str)?;
Ok(v)
} else {
Ok(BeatInfo::default())
}
}
}

#[derive(Debug, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -422,12 +483,7 @@ pub async fn beat_instance(
payload: web::Payload,
appdata: web::Data<Arc<AppShareData>>,
) -> impl Responder {
let body = match get_req_body(payload).await {
Ok(v) => v,
Err(err) => {
return HttpResponse::InternalServerError().body(err.to_string());
}
};
let body = get_req_body(payload).await.unwrap_or_default();
let b = match serde_urlencoded::from_bytes(&body) {
Ok(v) => v,
Err(err) => {
Expand Down Expand Up @@ -469,7 +525,7 @@ pub async fn beat_instance(
}
}
}
Err(e) => HttpResponse::InternalServerError().body(e),
Err(e) => HttpResponse::InternalServerError().body(e.to_string()),
}
}

Expand Down

0 comments on commit 9f376d8

Please sign in to comment.