Browse Source

OptionsSetting获取nacos实时数据调整,心跳时间延长

lichunlei 2 days ago
parent
commit
a8583ec0a5
2 changed files with 6 additions and 2 deletions
  1. 1 1
      App/App.cs
  2. 5 1
      appsettings.Development.json

+ 1 - 1
App/App.cs

@@ -9,7 +9,7 @@ namespace Infrastructure
         /// <summary>
         /// 全局配置文件
         /// </summary>
-        public static OptionsSetting OptionsSetting => CatchOrDefault(() => ServiceProvider?.GetService<IOptions<OptionsSetting>>()?.Value);
+        public static OptionsSetting OptionsSetting => CatchOrDefault(() => ServiceProvider?.GetService<IOptionsMonitor<OptionsSetting>>()?.CurrentValue);
 
         /// <summary>
         /// 服务提供器

+ 5 - 1
appsettings.Development.json

@@ -26,6 +26,10 @@
     "ConfigUseRpc": false,
     "NamingUseRpc": false,
     "RegisterEnabled": true,
-    "InstanceEnabled": true
+    "InstanceEnabled": true,
+    "Metadata": {
+      "preserved.heart.beat.interval": "30000",
+      "preserved.heart.beat.timeout": "60000"
+    }
   }
 }