diff --git a/code_snippets/ts/src/use_cases/signup_workflow.ts b/code_snippets/ts/src/use_cases/signup_workflow.ts index ece4274f..616e662a 100644 --- a/code_snippets/ts/src/use_cases/signup_workflow.ts +++ b/code_snippets/ts/src/use_cases/signup_workflow.ts @@ -2,7 +2,7 @@ import * as restate from "@restatedev/restate-sdk"; import {TerminalError, WorkflowContext, WorkflowSharedContext} from "@restatedev/restate-sdk"; // -const signUpWorkflow = restate.workflow({ +export default restate.workflow({ name: "sign-up-workflow", handlers: { run: async (ctx: WorkflowContext, user: User) => { @@ -41,8 +41,6 @@ const signUpWorkflow = restate.workflow({ }); // -export type SignUpWorkflow = typeof signUpWorkflow; - type KafkaEvent = { topic: string, message: string }; export type User = { id: string, name: string, email: string }; diff --git a/docs/use-cases/event-processing.mdx b/docs/use-cases/event-processing.mdx index 45b5547b..5e393c85 100644 --- a/docs/use-cases/event-processing.mdx +++ b/docs/use-cases/event-processing.mdx @@ -99,7 +99,7 @@ Restate pushes the events to your function. Here, we postpone processing for 5 seconds if the user profile is not ready yet. - ```ts user_updates.ts focus=6:11 mark=9 + ```ts user_updates.ts mark=9 CODE_LOAD::ts/src/use_cases/event_processing.ts ``` @@ -109,7 +109,7 @@ Restate pushes the events to your function. The results of interactions with external systems are tracked and recovered after failures. This simplifies writing flows that keep multiple systems in sync. - ```ts user_updates.ts focus=7,10,13:14 mark=7,10,13:14 + ```ts user_updates.ts mark=7,10,13:14 CODE_LOAD::ts/src/use_cases/event_processing.ts ``` @@ -121,7 +121,7 @@ Restate pushes the events to your function. Each event craft its own path through the code and builds up its own recovery log. - ```ts user_updates.ts focus=6:14 + ```ts user_updates.ts mark=8:14 CODE_LOAD::ts/src/use_cases/event_processing.ts ``` @@ -140,15 +140,9 @@ Restate pushes the events to your function. ## Stateful event processing with Restate - - - Implement stateful event handlers with Restate. +Implement stateful event handlers with Restate. - ```ts profile_service.ts - CODE_LOAD::ts/src/use_cases/events_state.ts - ``` - - --- + ### K/V State Store state in Restate and access it from other handlers. diff --git a/docs/use-cases/microservice-orchestration.mdx b/docs/use-cases/microservice-orchestration.mdx index 41a8376c..8f295f91 100644 --- a/docs/use-cases/microservice-orchestration.mdx +++ b/docs/use-cases/microservice-orchestration.mdx @@ -45,7 +45,7 @@ Turn functions into durable handlers with the Restate SDK. Restate makes them distributed and durable out-of-the-box. - ```ts role_updater.ts mark=1,4 focus=1:4,25 + ```ts role_updater.ts mark=1,4 CODE_LOAD::ts/src/use_cases/role_updater.ts ``` @@ -60,7 +60,7 @@ Turn functions into durable handlers with the Restate SDK. Other updates to the same user are queued and processed in order. Updates either succeed or fail, but never leave the user in an inconsistent state. - ```ts role_updater.ts mark=4 focus=1:4,25 + ```ts role_updater.ts mark=4 CODE_LOAD::ts/src/use_cases/role_updater.ts ``` @@ -71,7 +71,7 @@ Turn functions into durable handlers with the Restate SDK. Store results of interaction with external systems or non-deterministic actions. On retries, the action does not get re-executed but the previous result will be returned. - ```ts role_updater.ts focus=1:5,24,7,8,13:14 mark=7,8,13:14 + ```ts role_updater.ts mark=7,8,13:14 CODE_LOAD::ts/src/use_cases/role_updater.ts ``` @@ -84,7 +84,7 @@ Turn functions into durable handlers with the Restate SDK. Here, we update the user’s role in multiple systems. If one fails, we rollback the changes in the other systems. - ```ts role_updater.ts focus=10:24 mark=12:16,18 + ```ts role_updater.ts mark=12:16,18 CODE_LOAD::ts/src/use_cases/role_updater.ts ``` diff --git a/docs/use-cases/workflows.mdx b/docs/use-cases/workflows.mdx index 6d186dd3..48e8ff3b 100644 --- a/docs/use-cases/workflows.mdx +++ b/docs/use-cases/workflows.mdx @@ -47,7 +47,7 @@ Implement the `run` function of your workflow, using the Restate SDK. A workflow runs exactly one time. Restate makes sure that duplicate requests do not lead to duplicate execution. - ```ts user_sign_up_flow.ts focus=1:4,25 mark=1:4,25 + ```ts user_sign_up_flow.ts mark=1:4,25 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ``` @@ -60,7 +60,7 @@ Implement the `run` function of your workflow, using the Restate SDK. This lets you execute the steps of your workflows durably. - ```ts user_sign_up_flow.ts focus=1:4,24,8,11,12 mark=8,11,12 + ```ts user_sign_up_flow.ts mark=8,11,12 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ``` @@ -72,7 +72,7 @@ Implement the `run` function of your workflow, using the Restate SDK. Use Restate’s built-in key-value store to store workflow state. Restate guarantees that it is consistent and persistent, since state updates are tracked together with the rest of the execution progress. - ```ts user_sign_up_flow.ts focus=1:4,24,8,11,12,7,10,20,23 mark=7,10,20,23 + ```ts user_sign_up_flow.ts mark=7,10,20,23 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ``` @@ -82,7 +82,7 @@ Implement the `run` function of your workflow, using the Restate SDK. Retrieve the current state of the workflow from within other handlers and expose it to external clients. - ```ts user_sign_up_flow.ts focus=1:4,24,8,11,12,7,10,20,23,27 mark=27 + ```ts user_sign_up_flow.ts mark=27 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ``` @@ -93,7 +93,7 @@ Implement the `run` function of your workflow, using the Restate SDK. Make Promises/Futures resilient by registering them in Restate. Share them and wait until other functions resolve them. - ```ts user_sign_up_flow.ts focus=1:4,24,8,11,12,7,10,20,23,26:28,15 mark=15 + ```ts user_sign_up_flow.ts mark=15 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ``` @@ -104,7 +104,7 @@ Implement the `run` function of your workflow, using the Restate SDK. Notify the workflow of external signals, callbacks or Kafka events. Resolve or reject shared promises on which the workflow is waiting. The workflow handles the outcome. - ```ts user_sign_up_flow.ts focus=1:4,24,8,11,12,7,10,20,23,26:28,15,29:37 mark=29:35 + ```ts user_sign_up_flow.ts mark=29:35 CODE_LOAD::ts/src/use_cases/signup_workflow.ts ```