AgileConfig icon indicating copy to clipboard operation
AgileConfig copied to clipboard

使用IOptionsMonitor時,獲取的CurrentValue并不是最新的值

Open xbin-y opened this issue 3 years ago • 8 comments

使用IOptionsMonitor時,獲取的CurrentValue并不是最新的值。如果是通過配置文件修改的話,是能獲取到最新的。

xbin-y avatar Sep 16 '22 06:09 xbin-y

试了一下IOptionsMonitor没有问题。参考mvc示例代码 /home/ByOptionsMonitor

kklldog avatar Sep 16 '22 07:09 kklldog

试了一下IOptionsMonitor没有问题。参考mvc示例代码/home/ByOptionsMonitor

Snipaste_2022-09-16_19-12-06 你debug一下,這是我的測試截圖

xbin-y avatar Sep 16 '22 11:09 xbin-y

    public class GlobalOptions
    {
        public string OptionsTest { get; set; }
    }

builder.Services.Configure<GlobalOptions>(builder.Configuration.GetSection("Global"));

       public IndexModel(ILogger<IndexModel> logger, IConfiguration configuration, IOptionsMonitor<GlobalOptions> optionsMonitor)
        {
            _logger = logger;
            logger.LogInformation("test logger write .");
            _configuration = configuration;
            _optionsMonitor = optionsMonitor;

            Console.WriteLine(_optionsMonitor.CurrentValue.OptionsTest);
        }

info: AgileConfigMVCSampleNET6.Pages.IndexModel[0]
      test logger write .
test123123123
info: AgileConfigMVCSampleNET6.Pages.IndexModel[0]
      test logger write .
test123123123哥哥哥

看你是net6,我特地net6上试了一下,也没有问题。要么你把代码推到github上我看看。 你可以看看我的代码 https://github.com/kklldog/AgileConfig_Client/tree/master/AgileConfigMVCSampleNET6

kklldog avatar Sep 17 '22 14:09 kklldog

另外建议使用最新的client

kklldog avatar Sep 17 '22 14:09 kklldog

另外建议使用最新的client

https://github.com/yundexiaobin/agileconfig-option-debug.git 不過配置中心服務那邊不是最新的

xbin-y avatar Sep 19 '22 02:09 xbin-y

image 我用你的代码,连了一下我的测试服务器,貌似也没有问题。难得问题出再你的服务端?你加qq群 1022985150 ,这样沟通快一点。

kklldog avatar Sep 19 '22 05:09 kklldog

image 我用你的代码,连了一下我的测试服务器,貌似也没有问题。难得问题出再你的服务端?你加qq群 1022985150 ,这样沟通快一点。

version: '3' services: agile_config_admin: image: "kklldog/agile_config:release-1.3.8" #image: "kklldog/agile_config:v-1.6.8.1" ports: - "15000:5000" volumes: - /etc/localtime:/etc/localtime environment: - TZ=Asia/Shanghai - adminConsole=true - cluster=true - db__provider=mysql - db__conn= database=agileconfig;data source=192.168.30.100;User Id=****;password=*****;port=3306 #- db__conn= database=agile_config_new;data source=192.168.30.100;User Id=****;password=*****;port=3306

应该是版本的不一致的问题,用 1.3.8 版本的服务端和最新的client的话就会这样,用最新的服务端就没问题。不过我想升版本,用同一个数据库会报数据库缺字段

xbin-y avatar Sep 20 '22 05:09 xbin-y

1.3 到现在 1.6 跨度蛮大的,表结构有比较大的更新。建议用最新的版本跑一个空库出来,然后使用导出功能把1.3的配置都导出来,然后在1.6的版本上导入进去,这样的话会比较便捷。

kklldog avatar Sep 20 '22 08:09 kklldog