diff --git a/src/app/app.ts b/src/app/app.ts index 81367c7..4162a3f 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketServiceApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen(9080); diff --git a/src/auxiliary/email_client.ts b/src/auxiliary/email_client.ts index 1e41cbf..8125d8d 100644 --- a/src/auxiliary/email_client.ts +++ b/src/auxiliary/email_client.ts @@ -13,13 +13,13 @@ export class EmailClient { public static get() { return new EmailClient(); } - public notifyUserOfPaymentSuccess(userId: string): boolean { + async notifyUserOfPaymentSuccess(userId: string): Promise { console.log(`Notifying user ${userId} of payment success`); // send the email return true; } - public notifyUserOfPaymentFailure(userId: string): boolean { + async notifyUserOfPaymentFailure(userId: string): Promise { console.log(`Notifying user ${userId} of payment failure`); // send the email return true; diff --git a/src/part1/app.ts b/src/part1/app.ts index 81367c7..4162a3f 100644 --- a/src/part1/app.ts +++ b/src/part1/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketServiceApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen(9080); diff --git a/src/part2/app.ts b/src/part2/app.ts index 81367c7..4162a3f 100644 --- a/src/part2/app.ts +++ b/src/part2/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketServiceApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen(9080); diff --git a/src/part3/app.ts b/src/part3/app.ts index 81367c7..4162a3f 100644 --- a/src/part3/app.ts +++ b/src/part3/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketServiceApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen(9080); diff --git a/src/part3/checkout.ts b/src/part3/checkout.ts index ba8cd78..5fda161 100644 --- a/src/part3/checkout.ts +++ b/src/part3/checkout.ts @@ -26,20 +26,16 @@ const checkout = async ( const paymentClient = PaymentClient.get(); - const success = await paymentClient.call(idempotencyKey, totalPrice); + const success = await ctx.sideEffect(() => paymentClient.call(idempotencyKey, totalPrice)); const email = EmailClient.get(); if (success) { console.info("Payment successful. Notifying user about shipment."); - await ctx.sideEffect(async () => - email.notifyUserOfPaymentSuccess(request.userId), - ); + await ctx.sideEffect(() => email.notifyUserOfPaymentSuccess(request.userId)); } else { console.info("Payment failure. Notifying user about it."); - await ctx.sideEffect(async () => - email.notifyUserOfPaymentFailure(request.userId), - ); + await ctx.sideEffect( () => email.notifyUserOfPaymentFailure(request.userId)); } return success; diff --git a/src/part4/app.ts b/src/part4/app.ts index 81367c7..4162a3f 100644 --- a/src/part4/app.ts +++ b/src/part4/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketServiceApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen(9080); diff --git a/src/part4/checkout.ts b/src/part4/checkout.ts index 52b80cc..6b837ce 100644 --- a/src/part4/checkout.ts +++ b/src/part4/checkout.ts @@ -26,22 +26,17 @@ const checkout = async ( const paymentClient = PaymentClient.get(); - const doPayment = async () => - paymentClient.failingCall(idempotencyKey, totalPrice); + const doPayment = () => paymentClient.failingCall(idempotencyKey, totalPrice); const success = await ctx.sideEffect(doPayment); const email = EmailClient.get(); if (success) { console.info("Payment successful. Notifying user about shipment."); - await ctx.sideEffect(async () => - email.notifyUserOfPaymentSuccess(request.userId), - ); + await ctx.sideEffect( () => email.notifyUserOfPaymentSuccess(request.userId)); } else { console.info("Payment failure. Notifying user about it."); - await ctx.sideEffect(async () => - email.notifyUserOfPaymentFailure(request.userId), - ); + await ctx.sideEffect(() => email.notifyUserOfPaymentFailure(request.userId)); } return success;