File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#![ allow( unused_imports, unused_assignments, unused_variables) ]
22use crate :: common:: option_utils:: OptionUtils ;
3+ use crate :: common:: string_utils:: StringUtils ;
34use crate :: naming:: model:: { Instance , ServiceKey } ;
45use crate :: naming:: service:: { ServiceInfoDto , SubscriberInfoDto } ;
56use crate :: naming:: NamingUtils ;
@@ -250,7 +251,7 @@ impl BeatRequest {
250251
251252 pub fn convert_to_instance ( self ) -> anyhow:: Result < Instance > {
252253 let mut beat_info = self . get_beat_info ( ) ?;
253- let use_beat = self . beat . as_ref ( ) . is_some_and ( |s| !s . is_empty ( ) ) ;
254+ let use_beat = ! StringUtils :: is_option_empty ( & self . beat ) ;
254255 if !use_beat {
255256 beat_info. ip = self . ip ;
256257 beat_info. port = self . port ;
@@ -287,6 +288,9 @@ impl BeatRequest {
287288 }
288289
289290 fn get_beat_info ( & self ) -> anyhow:: Result < BeatInfo > {
291+ if StringUtils :: is_option_empty ( & self . beat ) {
292+ return Ok ( BeatInfo :: default ( ) ) ;
293+ }
290294 let beat_str = self . beat . clone ( ) . unwrap_or_default ( ) ;
291295 if let Some ( beat_str) = self . beat . as_ref ( ) {
292296 let v = serde_json:: from_str :: < BeatInfo > ( beat_str) ?;
You can’t perform that action at this time.
0 commit comments