Exemplo n.º 1
0
        public async Task <int> ScaleCollection(CosmosCollectionType cosmosRepositoryType, int requestUnits, int maxRequestUnits)
        {
            ICosmosDbScalingRepository cosmosDbScalingRepository = _cosmosDbScalingRepositoryProvider.GetRepository(cosmosRepositoryType);

            int throughPutRequestUnits = Math.Min(requestUnits, maxRequestUnits);

            try
            {
                await _scalingRepositoryPolicy.ExecuteAsync(async() => await cosmosDbScalingRepository.SetThroughput(throughPutRequestUnits));

                return(throughPutRequestUnits);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Failed to set throughput on repository type '{cosmosRepositoryType}' with '{requestUnits}' request units");

                throw;
            }
        }
Exemplo n.º 2
0
        private async Task ScaleCollection(CosmosCollectionType cosmosRepositoryType, int requestUnits)
        {
            ICosmosDbScalingRepository cosmosDbScalingRepository = _cosmosDbScalingRepositoryProvider.GetRepository(cosmosRepositoryType);

            try
            {
                await _scalingRepositoryPolicy.ExecuteAsync(() => cosmosDbScalingRepository.SetThroughput(requestUnits));
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Failed to set throughput on repository type '{cosmosRepositoryType}' with '{requestUnits}' request units");

                throw;
            }
        }