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(); }
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); }); }
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); }); }