-
Notifications
You must be signed in to change notification settings - Fork 2k
/
SQSStreamProviderUtils.cs
39 lines (36 loc) · 1.39 KB
/
SQSStreamProviderUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Orleans.Streams;
using OrleansAWSUtils.Storage;
using Orleans.Configuration;
namespace OrleansAWSUtils.Streams
{
/// <summary>
/// SQS utility functions
/// </summary>
public class SQSStreamProviderUtils
{
/// <summary>
/// Async method to delete all used queues, for specific provider and clusterId
/// </summary>
/// <returns> Task object for this async method </returns>
public static async Task DeleteAllUsedQueues(string providerName, string clusterId, string storageConnectionString, ILoggerFactory loggerFactory)
{
if (clusterId != null)
{
var queueMapper = new HashRingBasedStreamQueueMapper(new HashRingStreamQueueMapperOptions(), providerName);
List<QueueId> allQueues = queueMapper.GetAllQueues().ToList();
var deleteTasks = new List<Task>();
foreach (var queueId in allQueues)
{
var manager = new SQSStorage(loggerFactory, queueId.ToString(), storageConnectionString, clusterId);
manager.InitQueueAsync().Wait();
deleteTasks.Add(manager.DeleteQueue());
}
await Task.WhenAll(deleteTasks);
}
}
}
}