Exemplo n.º 1
0
        public DocumentDB(IAzureEndpoints AzureEndpoints)
        {
            var documentClient        = new DocumentClient(new Uri(AzureEndpoints.GetDocumentDBUrl()), AzureEndpoints.GetDocumentDBKey());
            var documentRetryStrategy = new DocumentDbRetryStrategy(RetryStrategy.DefaultExponential)
            {
                FastFirstRetry = true
            };

            dbClient = documentClient.AsReliable(documentRetryStrategy);
        }
        internal static IReliableReadWriteDocumentClient CreateClient(ConnectionSettings settings)
        {
            var client = new DocumentClient(new Uri(settings.EndpointUri), settings.AuthorizationKey, new ConnectionPolicy
            {
                ConnectionMode     = ConnectionMode.Direct,
                ConnectionProtocol = Protocol.Tcp
            });
            var documentRetryStrategy = new DocumentDbRetryStrategy(RetryStrategy.DefaultExponential)
            {
                FastFirstRetry = true
            };

            return(client.AsReliable(documentRetryStrategy));
        }
Exemplo n.º 3
0
        private static IReliableReadWriteDocumentClient CreateClient(string uri, string key)
        {
            ConnectionPolicy policy = new ConnectionPolicy()
            {
                ConnectionMode     = ConnectionMode.Direct,
                ConnectionProtocol = Protocol.Tcp
            };
            var documentClient        = new DocumentClient(new Uri(uri), key, policy);
            var documentRetryStrategy = new DocumentDbRetryStrategy(RetryStrategy.DefaultExponential)
            {
                FastFirstRetry = true
            };

            return(documentClient.AsReliable(documentRetryStrategy));
        }
Exemplo n.º 4
0
        public IReliableReadWriteDocumentClient GetClient(string endpointUrl, string authorizationKey, ConnectionPolicy connectionPolicy = null)
        {
            if (string.IsNullOrWhiteSpace(endpointUrl))
            {
                throw new ArgumentNullException("endpointUrl");
            }

            if (string.IsNullOrWhiteSpace(authorizationKey))
            {
                throw new ArgumentNullException("authorizationKey");
            }

            var documentClient = new DocumentClient(new Uri(endpointUrl), authorizationKey, connectionPolicy ?? new ConnectionPolicy());

            var documentRetryStrategy = new DocumentDbRetryStrategy(DocumentDbRetryStrategy.DefaultExponential)
            {
                FastFirstRetry = true
            };

            return(documentClient.AsReliable(documentRetryStrategy));
        }