Example #1
0
        public SlowDataStorageService(DataStorageServiceOptions options)
        {
            _options = options;
            _client  = new DocumentClient(options.Endpoint, options.ApiKey);

            _client.CreateDatabaseIfNotExistsAsync(new Database {
                Id = options.DatabaseName
            }).GetAwaiter().GetResult();
            _client.CreateDocumentCollectionIfNotExistsAsync(
                UriFactory.CreateDatabaseUri(options.DatabaseName),
                new DocumentCollection {
                Id = options.CollectionName
            })
            .GetAwaiter().GetResult();
        }
Example #2
0
 public DataStorageService(DataStorageServiceOptions options)
 {
     _collectionUri = UriFactory.CreateDocumentCollectionUri(options.DatabaseName, options.CollectionName);
     _clientFactory = new AsyncLazy <DocumentClient>(async() =>
     {
         var client = new DocumentClient(options.Endpoint, options.ApiKey);
         await client.CreateDatabaseIfNotExistsAsync(new Database {
             Id = options.DatabaseName
         });
         await client.CreateDocumentCollectionIfNotExistsAsync(
             UriFactory.CreateDatabaseUri(options.DatabaseName),
             new DocumentCollection {
             Id = options.CollectionName
         });
         return(client);
     });
 }
Example #3
0
        public DataStorageServiceWithTcp(DataStorageServiceOptions options)
        {
            _collectionUri = UriFactory.CreateDocumentCollectionUri(options.DatabaseName, options.CollectionName);
            _clientFactory = new AsyncLazy <DocumentClient>(async() =>
            {
                var client = new DocumentClient(options.Endpoint, options.ApiKey, new ConnectionPolicy
                {
                    ConnectionMode     = ConnectionMode.Direct,
                    ConnectionProtocol = Protocol.Tcp
                });

                await client.CreateDatabaseIfNotExistsAsync(new Database {
                    Id = options.DatabaseName
                });
                await client.CreateDocumentCollectionIfNotExistsAsync(
                    UriFactory.CreateDatabaseUri(options.DatabaseName),
                    new DocumentCollection {
                    Id = options.CollectionName
                });
                return(client);
            });
        }