Example #1
0
        private static async Task <OfferV2> GetDatabaseOfferAsync(this IDocumentClient documentClient, string databaseName)
        {
            var databaseUri = UriFactory.CreateDatabaseUri(databaseName);
            var database    = (await documentClient.ReadDatabaseAsync(databaseUri)).Resource;

            return(await documentClient.GetOfferFromSelfLinkAsync(database.SelfLink));
        }
Example #2
0
        private static async Task <OfferV2> GetCollectionOfferAsync(this IDocumentClient documentClient, string databaseName, string collectionName)
        {
            var collectionUri = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);
            var collection    = (await documentClient.ReadDocumentCollectionAsync(collectionUri)).Resource;

            return(await documentClient.GetOfferFromSelfLinkAsync(collection.SelfLink));
        }
Example #3
0
        public async Task ScaleDownAll()
        {
            var databases = _documentClient.CreateDatabaseQuery().AsEnumerable().ToList();

            foreach (var database in databases)
            {
                var offer = await _documentClient.GetOfferFromSelfLinkAsync(database.SelfLink);

                if (offer != null)
                {
                    await _documentClient.ScaleAsync(offer, _config.ScaleDownBatch, _config.MinThroughput, _config.MaxThroughput);
                }
                else
                {
                    var collections = _documentClient.CreateDocumentCollectionQuery(database.SelfLink).ToList();
                    foreach (var collection in collections)
                    {
                        offer = await _documentClient.GetOfferFromSelfLinkAsync(collection.SelfLink);

                        await _documentClient.ScaleAsync(offer, _config.ScaleDownBatch, _config.MinThroughput, _config.MaxThroughput);
                    }
                }
            }
        }