Exemplo n.º 1
0
 public ConsulConfigurationSource(ConfigurationOptions options, IConsulHandler consulHandler,
                                  IConsulKvEndpoint consulKvEndpoint)
 {
     Options          = options;
     ConsulKvEndpoint = consulKvEndpoint;
     ConsulHandler    = consulHandler;
 }
Exemplo n.º 2
0
        public static IConfigurationBuilder AddConsul(
            this IConfigurationBuilder builder,
            ConfigurationOptions configurationOptions,
            IConsulHandler consulHandler,
            IConsulKvEndpoint consulKvEndpoint
            )
        {
            var consulConfigurationSource =
                new ConsulConfigurationSource(configurationOptions, consulHandler, consulKvEndpoint);

            return(builder.Add(consulConfigurationSource));
        }
        public ConsulConfigurationProvider(ConfigurationOptions options, IConsulHandler consulHandler,
                                           IConsulKvEndpoint consulKvEndpoint)
        {
            _options          = options;
            _consulKvEndpoint = consulKvEndpoint;
            _consulHandler    = consulHandler;
            AutoReload        = _options.AutoReload;
            if (options.Watch != null)
            {
                ChangeToken.OnChange(
                    () => _consulKvEndpoint.Watch(_options.Watch !, _consulHandler.CancellationToken),
                    async() =>
                {
                    if (!AutoReload)
                    {
                        return;
                    }

                    await LoadAsync();
                    OnReload();
                });
            }
        }