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

Commit

Permalink
Replace doXYZ with XYZ
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Aug 21, 2023
1 parent 8a7d5d4 commit fce64b0
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/app/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

import * as restate from "@restatedev/restate-sdk";

const doCheckout = async (
const checkout = async (
ctx: restate.RpcContext,
request: { userId: string; tickets: string[] },
) => {
return true;
};

export const checkoutRouter = restate.router({
checkout: doCheckout,
checkout: checkout,
});

export const checkoutApi: restate.ServiceApi<typeof checkoutRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/app/ticket_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ enum TicketStatus {
Sold,
}

const doReserveTicket = async (ctx: restate.RpcContext) => {
const reserve = async (ctx: restate.RpcContext) => {
return true;
};

const doUnreserveTicket = async (ctx: restate.RpcContext) => {
const unreserve = async (ctx: restate.RpcContext) => {
return true;
};

const doMarkAsSold = async (ctx: restate.RpcContext) => {
const markAsSold = async (ctx: restate.RpcContext) => {
return true;
};

export const ticketDbRouter = restate.keyedRouter({
reserve: doReserveTicket,
unreserve: doUnreserveTicket,
markAsSold: doMarkAsSold,
reserve: reserve,
unreserve: unreserve,
markAsSold: markAsSold,
});

export const ticketServiceApi: restate.ServiceApi<typeof ticketDbRouter> = {
Expand Down
14 changes: 7 additions & 7 deletions src/app/user_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@

import * as restate from "@restatedev/restate-sdk";

const doAddTicket = async (
const addTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
) => {
return true;
};

const doExpireTicket = async (
const expireTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
) => {};
) => { };

const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
const checkout = async (ctx: restate.RpcContext, userId: string) => {
return true;
};

export const userSessionRouter = restate.keyedRouter({
addTicket: doAddTicket,
expireTicket: doExpireTicket,
checkout: doCheckout,
addTicket: addTicket,
expireTicket: expireTicket,
checkout: checkout,
});

export const userSessionApi: restate.ServiceApi<typeof userSessionRouter> = {
Expand Down
4 changes: 2 additions & 2 deletions src/part1/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

import * as restate from "@restatedev/restate-sdk";

const doCheckout = async (
const checkout = async (
ctx: restate.RpcContext,
request: { userId: string; tickets: string[] },
) => {
return true;
};

export const checkoutRouter = restate.router({
checkout: doCheckout,
checkout: checkout,
});

export const checkoutApi: restate.ServiceApi<typeof checkoutRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part1/ticket_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ enum TicketStatus {
Sold,
}

const doReserveTicket = async (ctx: restate.RpcContext) => {
const reserve = async (ctx: restate.RpcContext) => {
await setTimeout(35000);
return true;
};

const doUnreserveTicket = async (ctx: restate.RpcContext) => {
const unreserve = async (ctx: restate.RpcContext) => {
return true;
};

const doMarkAsSold = async (ctx: restate.RpcContext) => {
const markAsSold = async (ctx: restate.RpcContext) => {
return true;
};

export const ticketDbRouter = restate.keyedRouter({
reserve: doReserveTicket,
unreserve: doUnreserveTicket,
markAsSold: doMarkAsSold,
reserve: reserve,
unreserve: unreserve,
markAsSold: markAsSold,
});

export const ticketServiceApi: restate.ServiceApi<typeof ticketDbRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part1/user_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as restate from "@restatedev/restate-sdk";
import { ticketServiceApi } from "./ticket_service";
import { checkoutApi } from "./checkout";

const doAddTicket = async (
const addTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
Expand All @@ -22,25 +22,25 @@ const doAddTicket = async (
return true;
};

const doExpireTicket = async (
const expireTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
) => {
ctx.send(ticketServiceApi).unreserve(ticketId);
};

const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
const checkout = async (ctx: restate.RpcContext, userId: string) => {
const checkoutRequest = { userId: userId, tickets: ["456"] };
const success = await ctx.rpc(checkoutApi).checkout(checkoutRequest);

return success;
};

export const userSessionRouter = restate.keyedRouter({
addTicket: doAddTicket,
expireTicket: doExpireTicket,
checkout: doCheckout,
addTicket: addTicket,
expireTicket: expireTicket,
checkout: checkout,
});

export const userSessionApi: restate.ServiceApi<typeof userSessionRouter> = {
Expand Down
4 changes: 2 additions & 2 deletions src/part2/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

import * as restate from "@restatedev/restate-sdk";

const doCheckout = async (
const checkout = async (
ctx: restate.RpcContext,
request: { userId: string; tickets: string[] },
) => {
return true;
};

export const checkoutRouter = restate.router({
checkout: doCheckout,
checkout: checkout,
});

export const checkoutApi: restate.ServiceApi<typeof checkoutRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part2/ticket_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum TicketStatus {
Sold,
}

const doReserveTicket = async (ctx: restate.RpcContext) => {
const reserve = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -29,7 +29,7 @@ const doReserveTicket = async (ctx: restate.RpcContext) => {
}
};

const doUnreserveTicket = async (ctx: restate.RpcContext) => {
const unreserve = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -41,7 +41,7 @@ const doUnreserveTicket = async (ctx: restate.RpcContext) => {
}
};

const doMarkAsSold = async (ctx: restate.RpcContext) => {
const markAsSold = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -54,9 +54,9 @@ const doMarkAsSold = async (ctx: restate.RpcContext) => {
};

export const ticketDbRouter = restate.keyedRouter({
reserve: doReserveTicket,
unreserve: doUnreserveTicket,
markAsSold: doMarkAsSold,
reserve: reserve,
unreserve: unreserve,
markAsSold: markAsSold,
});

export const ticketServiceApi: restate.ServiceApi<typeof ticketDbRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part2/user_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as restate from "@restatedev/restate-sdk";
import { ticketServiceApi } from "./ticket_service";
import { checkoutApi } from "./checkout";

const doAddTicket = async (
const addTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
Expand All @@ -33,7 +33,7 @@ const doAddTicket = async (
return reservationSuccess;
};

const doExpireTicket = async (
const expireTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
Expand All @@ -50,7 +50,7 @@ const doExpireTicket = async (
}
};

const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
const checkout = async (ctx: restate.RpcContext, userId: string) => {
const tickets = await ctx.get<string[]>("tickets");

if (tickets === null || tickets.length === 0) {
Expand All @@ -69,9 +69,9 @@ const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
};

export const userSessionRouter = restate.keyedRouter({
addTicket: doAddTicket,
expireTicket: doExpireTicket,
checkout: doCheckout,
addTicket: addTicket,
expireTicket: expireTicket,
checkout: checkout,
});

export const userSessionApi: restate.ServiceApi<typeof userSessionRouter> = {
Expand Down
4 changes: 2 additions & 2 deletions src/part3/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { v4 as uuid } from "uuid";
import { PaymentClient } from "../aux/payment_client";
import { EmailClient } from "../aux/email_client";

const doCheckout = async (
const checkout = async (
ctx: restate.RpcContext,
request: { userId: string; tickets: string[] },
) => {
Expand Down Expand Up @@ -46,7 +46,7 @@ const doCheckout = async (
};

export const checkoutRouter = restate.router({
checkout: doCheckout,
checkout: checkout,
});

export const checkoutApi: restate.ServiceApi<typeof checkoutRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part3/ticket_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum TicketStatus {
Sold,
}

const doReserveTicket = async (ctx: restate.RpcContext) => {
const reserve = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -29,7 +29,7 @@ const doReserveTicket = async (ctx: restate.RpcContext) => {
}
};

const doUnreserveTicket = async (ctx: restate.RpcContext) => {
const unreserve = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -41,7 +41,7 @@ const doUnreserveTicket = async (ctx: restate.RpcContext) => {
}
};

const doMarkAsSold = async (ctx: restate.RpcContext) => {
const markAsSold = async (ctx: restate.RpcContext) => {
const status =
(await ctx.get<TicketStatus>("status")) || TicketStatus.Available;

Expand All @@ -54,9 +54,9 @@ const doMarkAsSold = async (ctx: restate.RpcContext) => {
};

export const ticketDbRouter = restate.keyedRouter({
reserve: doReserveTicket,
unreserve: doUnreserveTicket,
markAsSold: doMarkAsSold,
reserve: reserve,
unreserve: unreserve,
markAsSold: markAsSold,
});

export const ticketServiceApi: restate.ServiceApi<typeof ticketDbRouter> = {
Expand Down
12 changes: 6 additions & 6 deletions src/part3/user_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as restate from "@restatedev/restate-sdk";
import { ticketServiceApi } from "./ticket_service";
import { checkoutApi } from "./checkout";

const doAddTicket = async (
const addTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
Expand All @@ -33,7 +33,7 @@ const doAddTicket = async (
return reservationSuccess;
};

const doExpireTicket = async (
const expireTicket = async (
ctx: restate.RpcContext,
userId: string,
ticketId: string,
Expand All @@ -50,7 +50,7 @@ const doExpireTicket = async (
}
};

const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
const checkout = async (ctx: restate.RpcContext, userId: string) => {
const tickets = await ctx.get<string[]>("tickets");

if (tickets && tickets.length > 0) {
Expand All @@ -74,9 +74,9 @@ const doCheckout = async (ctx: restate.RpcContext, userId: string) => {
};

export const userSessionRouter = restate.keyedRouter({
addTicket: doAddTicket,
expireTicket: doExpireTicket,
checkout: doCheckout,
addTicket: addTicket,
expireTicket: expireTicket,
checkout: checkout,
});

export const userSessionApi: restate.ServiceApi<typeof userSessionRouter> = {
Expand Down
4 changes: 2 additions & 2 deletions src/part4/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { v4 as uuid } from "uuid";
import { EmailClient } from "../aux/email_client";
import { PaymentClient } from "../aux/payment_client";

const doCheckout = async (
const checkout = async (
ctx: restate.RpcContext,
request: { userId: string; tickets: string[] },
) => {
Expand Down Expand Up @@ -48,7 +48,7 @@ const doCheckout = async (
};

export const checkoutRouter = restate.router({
checkout: doCheckout,
checkout: checkout,
});

export const checkoutApi: restate.ServiceApi<typeof checkoutRouter> = {
Expand Down
Loading

0 comments on commit fce64b0

Please sign in to comment.