Skip to content

Commit

Permalink
完成注册中心服务实例增加注册到系统的时间字段后端开发 #177
Browse files Browse the repository at this point in the history
  • Loading branch information
heqingpan committed Dec 2, 2024
1 parent 2cc8d1f commit 0b64b92
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/grpc/handler/naming_batch_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl BatchInstanceRequestHandler {
group_service: Default::default(),
metadata: input.metadata.unwrap_or_default(),
last_modified_millis: last_modified_millis.to_owned(),
register_time: last_modified_millis,
namespace_id: namesapce_id.clone(),
app_name: "".to_owned(),
from_grpc: true,
Expand Down
4 changes: 3 additions & 1 deletion src/grpc/handler/naming_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl InstanceRequestHandler {
} else {
return Err(anyhow::format_err!("serivceName is unvaild!"));
};
let now = now_millis_i64();
let mut instance = Instance {
id: Default::default(),
ip: input.ip.unwrap(),
Expand All @@ -75,7 +76,8 @@ impl InstanceRequestHandler {
group_name,
group_service: Default::default(),
metadata: input.metadata.unwrap_or_default(),
last_modified_millis: now_millis_i64(),
last_modified_millis: now,
register_time: now,
namespace_id: Arc::new(NamingUtils::default_namespace(
request.namespace.unwrap_or_default(),
)),
Expand Down
2 changes: 2 additions & 0 deletions src/naming/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct Instance {
pub group_service: Arc<String>,
pub metadata: Arc<HashMap<String, String>>,
pub last_modified_millis: i64,
pub register_time: i64,
pub namespace_id: Arc<String>,
pub app_name: String,
pub from_grpc: bool,
Expand Down Expand Up @@ -124,6 +125,7 @@ impl Default for Instance {
group_service: Default::default(),
metadata: Default::default(),
last_modified_millis: Default::default(),
register_time: now_millis_i64(),
namespace_id: Default::default(),
app_name: Default::default(),
from_grpc: false,
Expand Down
1 change: 1 addition & 0 deletions src/naming/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl Service {
let old_instance = self.instances.get(&key);
let mut replace_old_client_id = None;
if let Some(old_instance) = old_instance {
instance.register_time = old_instance.register_time;
if !instance.from_grpc && old_instance.from_grpc {
/*
match (old_instance.from_grpc, old_instance.is_from_cluster()) {
Expand Down

0 comments on commit 0b64b92

Please sign in to comment.