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