Created
September 11, 2021 06:46
-
-
Save davidobrien1985/afa527c9a8648cafe52043d7dcb5097a to your computer and use it in GitHub Desktop.
repro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InventoryBulkStorage : IInventoryBulkStorage | |
{ | |
private readonly CosmosContainer _containerId = CosmosContainer.Inventory; | |
private readonly bool _isBulk = true; | |
public async Task UpsertBulkAsync(IEnumerable<InventoryResource> resources) | |
{ | |
var containers = CosmosProvider.Containers | |
.Where(c => c.ContainerId == _containerId && c.IsBulk == _isBulk) | |
.ToDictionary(k => k.Region, v => v.Container); | |
var concurrentTasks = new List<Task>(); | |
foreach (var resource in resources) | |
{ | |
var region = await AppDataCache.GetCustomerRegionAsync(resource.CustomerId); | |
concurrentTasks.Add(containers[region].UpsertItemAsync(resource, new PartitionKey(resource.CustomerId), new ItemRequestOptions() | |
{ | |
EnableContentResponseOnWrite = false, | |
})); | |
} | |
await Task.WhenAll(concurrentTasks); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment