Skip to content

Commit

Permalink
Fix some uniformity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mjameswh committed Jan 8, 2025
1 parent ad7ecd8 commit a1ee719
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 140 deletions.
2 changes: 1 addition & 1 deletion early-return/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
22
4 changes: 2 additions & 2 deletions early-return/.post-create
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Start Temporal Server:

{cyan temporal server start-dev}

Use Node version 16+:
Use Node version 18+ (v22.x is recommended):

Mac: {cyan brew install node@16}
Mac: {cyan brew install node@22}
Other: https://nodejs.org/en/download/

Then, in the project directory, using two other shells, run these commands:
Expand Down
28 changes: 17 additions & 11 deletions early-return/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Early Return

This sample demonstrates how to use the "Early Return" pattern via update-with-start.

The "Early Return" pattern involves using update-with-start to start a Workflow and send an Update in the
first Workflow Task. The Update handler waits until the Workflow reaches a certain state of interest, and then
returns some data to the caller. The Workflow continues to execute in the background, and the caller has
possession of a `WorkflowHandle` to follow up on the Workflow progress.
The "Early Return" pattern involves using update-with-start to start a Workflow and send an Update
in the first Workflow Task. The Update handler waits until the Workflow reaches a certain state of
interest, and then returns some data to the caller. The Workflow continues to execute in the background,
and the caller has possession of a `WorkflowHandle` to follow up on the Workflow progress.

In this example, the Workflow represents a financial transaction, and we use Early Return to wait until the
transaction has been confirmed, leaving the Workflow to complete the remaining stages of the transaction in
the background.
In this example, the Workflow represents a financial transaction, and we use Early Return to wait
until the transaction has been confirmed, leaving the Workflow to complete the remaining stages of
the transaction in the background.

### Running this sample

1. `pnpm install` to install dependencies.
1. Run a Temporal Server via `temporal server start-dev --dynamic-config-value frontend.enableExecuteMultiOperation=true`, using at least version `v1.1.2` of the `temporal` CLI.
1. `pnpm run start.watch` to start the Worker.
1 `pnpm run workflow tx-abc123` to run a transaction workflow, obtaining an "early return" via Update-With-Start.
1. Start a Temporal Server via:
```
temporal server start-dev --dynamic-config-value frontend.enableExecuteMultiOperation=true
```
Update-with-Start requires version `v1.1.2` or later of the `temporal` CLI.
2. `npm install` to install dependencies (or `pnpm` or `yarn`).
3. `npm run start.watch` to start the Worker.
4 `npm run workflow tx-abc123` to run a transaction workflow, obtaining an "early return" via Update-With-Start.
12 changes: 7 additions & 5 deletions early-return/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"build": "tsc --build",
"build.watch": "tsc --build --watch",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "eslint .",
"start": "ts-node src/worker.ts",
"start.watch": "nodemon src/worker.ts",
Expand All @@ -21,15 +23,15 @@
]
},
"dependencies": {
"@temporalio/activity": "file:~/src/temporalio/sdk-typescript/packages/activity",
"@temporalio/client": "file:~/src/temporalio/sdk-typescript/packages/client",
"@temporalio/worker": "file:~/src/temporalio/sdk-typescript/packages/worker",
"@temporalio/workflow": "file:~/src/temporalio/sdk-typescript/packages/workflow",
"@temporalio/activity": "^1.11.6",
"@temporalio/client": "^1.11.6",
"@temporalio/worker": "^1.11.6",
"@temporalio/workflow": "^1.11.6",
"async-mutex": "^0.5.0",
"nanoid": "3.x"
},
"devDependencies": {
"@temporalio/testing": "file:~/src/temporalio/sdk-typescript/packages/testing",
"@temporalio/testing": "^1.11.6",
"@tsconfig/node18": "^18.2.4",
"@types/mocha": "8.x",
"@types/node": "^22.9.1",
Expand Down
131 changes: 10 additions & 121 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1ee719

Please sign in to comment.