-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderFlow.cs
More file actions
28 lines (22 loc) · 910 Bytes
/
OrderFlow.cs
File metadata and controls
28 lines (22 loc) · 910 Bytes
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
using Cleipnir.Flows.Sample.Flows.Ordering.Rpc.Clients;
using Cleipnir.ResilientFunctions.Domain;
namespace Cleipnir.Flows.Sample.Flows.Ordering.Rpc;
[GenerateFlows]
public class OrderFlow(
IPaymentProviderClient paymentProviderClient,
IEmailClient emailClient,
ILogisticsClient logisticsClient
) : Flow<Order>
{
public override async Task Run(Order order)
{
var transactionId = await Capture("TransactionId", Guid.NewGuid);
await paymentProviderClient.Reserve(transactionId, order.CustomerId, order.TotalPrice);
var trackAndTrace = await Capture(
() => logisticsClient.ShipProducts(order.CustomerId, order.ProductIds),
ResiliencyLevel.AtMostOnce
);
await paymentProviderClient.Capture(transactionId);
await emailClient.SendOrderConfirmation(order.CustomerId, trackAndTrace, order.ProductIds);
}
}