public GlobalEndpointManager(IDocumentClientInternal owner, ConnectionPolicy connectionPolicy) { this.locationCache = new LocationCache( new ReadOnlyCollection <string>(connectionPolicy.PreferredLocations), owner.ServiceEndpoint, connectionPolicy.EnableEndpointDiscovery, connectionPolicy.MaxConnectionLimit, connectionPolicy.UseMultipleWriteLocations); this.owner = owner; this.defaultEndpoint = owner.ServiceEndpoint; this.connectionPolicy = connectionPolicy; this.databaseAccountCache = new AsyncCache <string, CosmosAccountSettings>(); this.connectionPolicy.PreferenceChanged += this.OnPreferenceChanged; this.isRefreshing = false; this.refreshLock = new object(); #if !(NETSTANDARD15 || NETSTANDARD16) string backgroundRefreshLocationTimeIntervalInMSConfig = System.Configuration.ConfigurationManager.AppSettings[GlobalEndpointManager.BackgroundRefreshLocationTimeIntervalInMS]; if (!string.IsNullOrEmpty(backgroundRefreshLocationTimeIntervalInMSConfig)) { if (!int.TryParse(backgroundRefreshLocationTimeIntervalInMSConfig, out this.backgroundRefreshLocationTimeIntervalInMS)) { this.backgroundRefreshLocationTimeIntervalInMS = GlobalEndpointManager.DefaultBackgroundRefreshLocationTimeIntervalInMS; } } #endif }
public GlobalEndpointManager(IDocumentClientInternal owner, ConnectionPolicy connectionPolicy) { this.locationCache = new LocationCache( new ReadOnlyCollection <string>(connectionPolicy.PreferredLocations), owner.ServiceEndpoint, connectionPolicy.EnableEndpointDiscovery, connectionPolicy.MaxConnectionLimit, connectionPolicy.UseMultipleWriteLocations); this.owner = owner; this.defaultEndpoint = owner.ServiceEndpoint; this.connectionPolicy = connectionPolicy; this.connectionPolicy.PreferenceChanged += this.OnPreferenceChanged; #if !(NETSTANDARD15 || NETSTANDARD16) #if NETSTANDARD20 // GetEntryAssembly returns null when loaded from native netstandard2.0 if (System.Reflection.Assembly.GetEntryAssembly() != null) { #endif string backgroundRefreshLocationTimeIntervalInMSConfig = System.Configuration.ConfigurationManager.AppSettings[GlobalEndpointManager.BackgroundRefreshLocationTimeIntervalInMS]; if (!string.IsNullOrEmpty(backgroundRefreshLocationTimeIntervalInMSConfig)) { if (!int.TryParse(backgroundRefreshLocationTimeIntervalInMSConfig, out this.backgroundRefreshLocationTimeIntervalInMS)) { this.backgroundRefreshLocationTimeIntervalInMS = GlobalEndpointManager.DefaultBackgroundRefreshLocationTimeIntervalInMS; } } #if NETSTANDARD20 } #endif #endif string minimumIntervalForNonForceRefreshLocationInMSConfig = Environment.GetEnvironmentVariable(GlobalEndpointManager.MinimumIntervalForNonForceRefreshLocationInMS); if (!string.IsNullOrEmpty(minimumIntervalForNonForceRefreshLocationInMSConfig)) { if (int.TryParse(minimumIntervalForNonForceRefreshLocationInMSConfig, out int minimumIntervalForNonForceRefreshLocationInMS)) { this.MinTimeBetweenAccountRefresh = TimeSpan.FromMilliseconds(minimumIntervalForNonForceRefreshLocationInMS); } else { DefaultTrace.TraceError($"GlobalEndpointManager: Failed to parse {GlobalEndpointManager.MinimumIntervalForNonForceRefreshLocationInMS}; Value:{minimumIntervalForNonForceRefreshLocationInMSConfig}"); } } }
public GlobalEndpointManager(IDocumentClientInternal owner, ConnectionPolicy connectionPolicy) { this.locationCache = new LocationCache( new ReadOnlyCollection <string>(connectionPolicy.PreferredLocations), owner.ServiceEndpoint, connectionPolicy.EnableEndpointDiscovery, connectionPolicy.MaxConnectionLimit, connectionPolicy.UseMultipleWriteLocations); this.owner = owner; this.defaultEndpoint = owner.ServiceEndpoint; this.connectionPolicy = connectionPolicy; this.databaseAccountCache = new AsyncCache <string, AccountProperties>(); this.connectionPolicy.PreferenceChanged += this.OnPreferenceChanged; this.isRefreshing = false; this.refreshLock = new object(); #if !(NETSTANDARD15 || NETSTANDARD16) #if NETSTANDARD20 // GetEntryAssembly returns null when loaded from native netstandard2.0 if (System.Reflection.Assembly.GetEntryAssembly() != null) { #endif string backgroundRefreshLocationTimeIntervalInMSConfig = System.Configuration.ConfigurationManager.AppSettings[GlobalEndpointManager.BackgroundRefreshLocationTimeIntervalInMS]; if (!string.IsNullOrEmpty(backgroundRefreshLocationTimeIntervalInMSConfig)) { if (!int.TryParse(backgroundRefreshLocationTimeIntervalInMSConfig, out this.backgroundRefreshLocationTimeIntervalInMS)) { this.backgroundRefreshLocationTimeIntervalInMS = GlobalEndpointManager.DefaultBackgroundRefreshLocationTimeIntervalInMS; } } #if NETSTANDARD20 } #endif #endif }