EDU-3801: Update Money Transfer tutorial code to support Temporal Cloud #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE.
I have created this draft PR to support review and sharing this code. However, I do not intend for this code to become part of the
main
branch, as it is my hope that what's on this branch will become obsolete when the SDKs support environment-based configuration.What was changed
I added code to configure Temporal Client options based on the presence of environment variables. I also updated the Clients created by the Worker and Starter code to use it.
Why?
Currently, the clients used in this tutorial have no explicit configuration and rely solely on the default options. Imagine that someone new to Temporal application development signed up for Temporal Cloud on their own and now wants to run this intro-level money transfer tutorial. Getting it to work with Temporal Cloud requires making changes to the Client configuration, but this user won't know what to change. Note that this scenario I've described isn't limited to Temporal Cloud. Someone using a non-default Namespace name or a non-local Temporal Service would have the same problem.
Having the clients configure themselves based on the presence of environment variables eliminates the need to hardcode the frontend address, Namespace name, or authentication details. It helps the user understand that the application logic remains unchanged when migrating from the Temporal Service used for development on their laptop to a production Temporal Service (or vice versa). Finally, this makes it easier for users to run this example locally, on a remote self-hosted cluster, or on Temporal Cloud. Unfortunately, the SDKs do not support this yet (although it has been discussed), so this has to be done within the application itself in the interim.
NOTE: I have updated the code but not the prose in the tutorial, pending further discussion with the Education team. I plan to make similar changes to the other money-transfer repos, but if it turns out that is not viable, then I will probably need to fork these repos and tutorials to support the onboarding path for new cloud users.
Checklist
This does not close an issue, but enables further progress of EDU-3801. That issue would be closed only after all similar tutorials have been updated.
I tested this in three scenarios:
Local Temporal Service (started via CLI) using the
default
namespace.In this scenario, I set no environment variables. I ran the Worker and Starter code and the Workflow ran to completion.
Temporal Cloud, using mTLS
In this scenario, I set the four environment variables below (note that these values are similar to but not identical to the ones I actually set):
To verify that mTLS was used for authentication, I disabled API Keys for authentication on the Namespace in this scenario. I then ran the Worker and Starter code and the Workflow ran to completion.
Temporal Cloud, using API Keys
In this scenario, I set the three environment variables below (note that these values are similar to but not identical to the ones I actually set):
To verify that the API keys were used for authentication, I disabled mTLS authentication on the Namespace in this scenario. I then ran the Worker and Starter code and the Workflow ran to completion.
The tutorial prose will require a small update to describe the changes and explain which environment variables one must set for non-default scenarios.