Beispiel #1
0
 private RemoteConfigs(ApolloOptions apolloOptions)
 {
     _apolloOptions = apolloOptions;
     if (_httpClient == null)
     {
         _httpClient = new HttpClient
         {
             BaseAddress = new Uri(_apolloOptions.MetaServer.Trim()),
             //由于服务端会hold住请求60秒,所以请确保客户端访问服务端的超时时间要大于60秒。->摘抄自官方文档
             Timeout = TimeSpan.FromSeconds(65)
         };
     }
 }
Beispiel #2
0
    public static IHostBuilder AddApollo(this IHostBuilder hostBuilder, Action <ApolloOptions> configure)
    {
        if (configure == null)
        {
            throw new ArgumentNullException(nameof(configure));
        }

        var options = new ApolloOptions();

        configure(options);

        return(hostBuilder.ConfigureAppConfiguration((_, builder) => builder.AddApollo(options)));
    }
Beispiel #3
0
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <param name="apolloOptions"></param>
        /// <returns></returns>
        internal static RemoteConfigs GetInstance(ApolloOptions apolloOptions)
        {
            var model = new RemoteConfigs(apolloOptions);

            return(model);
        }