Skip to content

Commit

Permalink
Fix missing awaits and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Nov 19, 2024
1 parent be1f82f commit 6af13cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions basics/basics-typescript/src/3_workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const myWorkflow = restate.workflow({
handlers: {
run: async (ctx: restate.WorkflowContext, params: { name: string; email: string }) => {
const {name, email} = params;
const userId = ctx.key;

// publish state, for the world to see our progress
ctx.set("stage", "Creating User");
Expand All @@ -41,7 +40,7 @@ const myWorkflow = restate.workflow({

// send the email with the verification secret
const secret = ctx.rand.uuidv4();
ctx.run(() => sendEmailWithLink({email, secret}));
await ctx.run(() => sendEmailWithLink({email, secret}));

try {
// the promise here is resolved or rejected by the additional workflow methods below
Expand Down Expand Up @@ -83,7 +82,12 @@ export type WorkflowApi = typeof myWorkflow;
// ---------- ⬆️⬆️ deploy this as a container, lambda, etc. ⬆️⬆️ ----------

// start it via an HTTP call.
// `curl restate:8080/usersignup/signup-userid1/run/send --json '{ "name": "Bob", "email": "bob@builder.com" }'
// curl localhost:8080/usersignup/signup-userid1/run/send --json '{ "name": "Bob", "email": "bob@builder.com" }'
//
// Resolve the email link via:
// curl localhost:8080/usersignup/signup-userid1/verifyEmail
// Abort the email verification via:
// curl localhost:8080/usersignup/signup-userid1/abortVerification

// or programmatically
async function signupUser(userId: string, name: string, email: string) {
Expand Down
6 changes: 3 additions & 3 deletions basics/basics-typescript/src/4_virtual_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const greeterObject = restate.object({

// you can call this now through http directly the following way

example1: `curl localhost:8080/greeter/mary/greet -H 'content-type: application/json' -d '{ "greeting" : "Hi" }'`;
example2: `curl localhost:8080/greeter/barack/greet -H 'content-type: application/json' -d '{"greeting" : "Hello" }'`;
example3: `curl localhost:8080/greeter/mary/ungreet -H 'content-type: application/json' -d '{}'`;
// example1: `curl localhost:8080/greeter/mary/greet -H 'content-type: application/json' -d '{ "greeting" : "Hi" }'`;
// example2: `curl localhost:8080/greeter/barack/greet -H 'content-type: application/json' -d '{"greeting" : "Hello" }'`;
// example3: `curl localhost:8080/greeter/mary/ungreet -H 'content-type: application/json' -d '{}'`;

// --------------------------------- deploying --------------------------------

Expand Down
2 changes: 1 addition & 1 deletion basics/basics-typescript/src/5_events_processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const userUpdates = restate.object({
// The other events for this Virtual Object / key are queued.
// Events for other keys are processed concurrently.
// The sleep suspends the function (e.g., when running on FaaS).
ctx.sleep(5_000);
await ctx.sleep(5_000);
userId = await ctx.run(() => updateUserProfile(profile));
}

Expand Down
2 changes: 1 addition & 1 deletion basics/basics-typescript/src/utils/example_stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function tryApplyPermission(
const { permissionKey, setting } = permission;
maybeCrash(0.3); // sometimes infra goes away

if (setting !== "blocked") {
if (setting !== "block") {
applicationError(
0.4,
`Could not apply permission ${permissionKey}:${setting} for user ${userId} due to a conflict.`
Expand Down

0 comments on commit 6af13cf

Please sign in to comment.