-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSupportTicketFlow.cs
More file actions
28 lines (23 loc) · 1.03 KB
/
Copy pathSupportTicketFlow.cs
File metadata and controls
28 lines (23 loc) · 1.03 KB
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
namespace Cleipnir.Flows.Sample.Presentation.G_SupportTicket.Solution;
public class SupportTicketFlow : Flow<SupportTicketRequest>
{
public override async Task Run(SupportTicketRequest request)
{
var (supportTicketId, customerSupportAgents) = request;
for (var i = 0;; i++)
{
var customerSupportAgent = customerSupportAgents[i % customerSupportAgents.Length];
await Effect.Capture(
() => RequestSupportForTicket(supportTicketId, customerSupportAgent, iteration: i)
);
var response = await Message<SupportTicketResponse>(
m => m.Iteration == i,
TimeSpan.FromMinutes(15)
);
if (response is SupportTicketTaken)
return; //ticket was taken in iteration i
}
}
private Task RequestSupportForTicket(Guid supportTicketId, string customerSupportAgent, int iteration)
=> MessageBroker.Send(new TakeSupportTicket(supportTicketId, customerSupportAgent, iteration));
}