Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Change port to 9080 and small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Oct 24, 2023
1 parent 33a9eef commit 3b5b811
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketServiceApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen(9080);
4 changes: 2 additions & 2 deletions src/auxiliary/email_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export class EmailClient {
public static get() {
return new EmailClient();
}
public notifyUserOfPaymentSuccess(userId: string): boolean {
async notifyUserOfPaymentSuccess(userId: string): Promise<boolean> {
console.log(`Notifying user ${userId} of payment success`);
// send the email
return true;
}

public notifyUserOfPaymentFailure(userId: string): boolean {
async notifyUserOfPaymentFailure(userId: string): Promise<boolean> {
console.log(`Notifying user ${userId} of payment failure`);
// send the email
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/part1/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketServiceApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen(9080);
2 changes: 1 addition & 1 deletion src/part2/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketServiceApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen(9080);
2 changes: 1 addition & 1 deletion src/part3/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketServiceApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen(9080);
10 changes: 3 additions & 7 deletions src/part3/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/part4/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketServiceApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen(9080);
11 changes: 3 additions & 8 deletions src/part4/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3b5b811

Please sign in to comment.