private static ConnectionPolicy CreateConnectionPolicy(DocumentDbConnectionMode?connectionMode, IDataTransferContext context) { return(DocumentDbClientHelper.ApplyConnectionMode(new ConnectionPolicy { UserAgentSuffix = String.Format(CultureInfo.InvariantCulture, Resources.CustomUserAgentSuffixFormat, Assembly.GetExecutingAssembly().GetName().Version, context.SourceName, context.SinkName) }, connectionMode)); }
private static ConnectionPolicy CreateConnectionPolicy(DocumentDbConnectionMode?connectionMode, IDataTransferContext context, bool isShardedImport) { var entryAssembly = Assembly.GetEntryAssembly(); return(DocumentDbClientHelper.ApplyConnectionMode(new ConnectionPolicy { UserAgentSuffix = String.Format(CultureInfo.InvariantCulture, Resources.CustomUserAgentSuffixFormat, entryAssembly == null ? Resources.UnknownEntryAssembly : entryAssembly.GetName().Name, Assembly.GetExecutingAssembly().GetName().Version, context.SourceName, context.SinkName, isShardedImport ? Resources.ShardedImportDesignator : String.Empty) }, connectionMode)); }
private static ConnectionPolicy CreateConnectionPolicy(DocumentDbConnectionMode?connectionMode, IDataTransferContext context, bool isShardedImport, int?maxConnectionLimit, int?retries, TimeSpan?retryInterval) { var entryAssembly = Assembly.GetEntryAssembly(); var connectionPolicy = new ConnectionPolicy { UserAgentSuffix = String.Format(CultureInfo.InvariantCulture, Resources.CustomUserAgentSuffixFormat, entryAssembly == null ? Resources.UnknownEntryAssembly : entryAssembly.GetName().Name, Assembly.GetExecutingAssembly().GetName().Version, context.SourceName, context.SinkName, isShardedImport ? Resources.ShardedImportDesignator : String.Empty) }; RetryOptions retryOptions = new RetryOptions(); if (retries.HasValue) { retryOptions.MaxRetryAttemptsOnThrottledRequests = retries.Value; } if (retryInterval.HasValue) { retryOptions.MaxRetryWaitTimeInSeconds = retryInterval.Value.Seconds; } connectionPolicy.RetryOptions = retryOptions; if (maxConnectionLimit.HasValue) { connectionPolicy.MaxConnectionLimit = maxConnectionLimit.Value; } return(DocumentDbClientHelper.ApplyConnectionMode(connectionPolicy, connectionMode)); }
private static DocumentClient CreateRawClient(IDocumentDbConnectionSettings connectionSettings, DocumentDbConnectionMode?connectionMode, IDataTransferContext context, bool isShardedImport, int?maxConnectionLimit, int?retries, TimeSpan?retryInterval, bool?ignoreSSLCertErrors = false) { Guard.NotNull("connectionSettings", connectionSettings); return(new DocumentClient( new Uri(connectionSettings.AccountEndpoint), connectionSettings.AccountKey, ignoreSSLCertErrors.GetValueOrDefault() ? DocumentDbClientHelper.GetSSLCertHandler() : null, !ignoreSSLCertErrors.GetValueOrDefault() ? CreateConnectionPolicy(connectionMode, context, isShardedImport, maxConnectionLimit, retries, retryInterval) : null )); }