-
Notifications
You must be signed in to change notification settings - Fork 0
/
orchestration.ts
44 lines (37 loc) · 1023 Bytes
/
orchestration.ts
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
40
41
42
43
44
import { task, workflow } from "@eventual/core";
export const processOrder = workflow(
"processOrder",
async (orderId: string) => {
const paymentId = await processPayment(orderId);
const shippingId = await shipOrder(orderId);
await updateOrderStatus({
orderId,
status: "Shipped",
});
return {
orderId,
paymentId,
shippingId,
};
}
);
export const processPayment = task(
"processPayment",
async (orderId: string) => {
// (integrate with your payment API, e.g. Stripe)
console.log("processing order", orderId);
return "payment-id";
}
);
export const shipOrder = task("shipOrder", async (orderId: string) => {
// integrate with the shipping API (etc.)
console.log("shipping order", orderId);
return "tracking-id";
});
export const updateOrderStatus = task(
"updateOrderStatus",
async (input: { orderId: string; status: string }) => {
// update the order database (e.g. DynamoDB)
console.log("updating order", input);
}
);