Skip to main content

Temporal workflows on Diagrid

Diagrid can run workflows written with the Temporal SDKs. You keep your workflow and activity code, your workers and your clients. You point them at Diagrid instead of a Temporal server, and Diagrid runs the workflows and stores their history.

Preview

Temporal workflows on Diagrid are in preview. Features and behavior can change before general availability, and not every region supports them yet.

How it works​

  • A Diagrid App is your Temporal namespace. You create an App that uses the Temporal workflow API. Its name is the namespace your workers and clients use.
  • Your code talks to Diagrid with the Temporal SDK. Workers poll Diagrid for tasks and clients start, signal, query and update workflows, as they would with a Temporal server.
  • Diagrid runs the server side. There's no Temporal server, database or visibility store to run.
  • You see your workflows in Diagrid. Temporal workflows appear in the workflows view of the Diagrid Web Console, with their history.
Temporal workers and clients on DiagridDiagridYour environmentWorkersTemporal SDKClients & CLITemporal SDK, CLIApp: ordersTemporal namespaceWorkflow historyWorkflows viewpoll tasksstart, signal, query
Temporal workers and clients on DiagridWorkers and clients connect to a Diagrid App as their namespace. Diagrid runs the server side and stores the history, so there is no Temporal server, database or visibility store to run.

Diagrid is tested with the Temporal Go, Java, Python and TypeScript SDKs, and with the Temporal CLI.

Set up a Temporal App​

You need the Diagrid CLI, logged in with diagrid login. On macOS and Linux you also need jq.

1. Create a project and an App​

Create a project, then an App that uses the Temporal workflow API. Projects created with diagrid CLI 1.119.0 or later get the managed workflow store by default. With CLI 1.118.0 or older, the project has no workflow store, and diagrid app create --workflow-api temporal fails. Upgrade the CLI, or run diagrid project update my-project --enable-managed-workflow for a project that already exists:

diagrid project create my-project --use
diagrid app create orders --workflow-api temporal --wait

You choose the workflow API when you create the App, and you can't change it later. If your region doesn't support Temporal workflows yet, diagrid app create says so.

2. Set Temporal's connection settings​

Temporal's SDKs and CLI read their connection settings from environment variables. Set them to your project's endpoint, the App's name and the App's API token:

export TEMPORAL_ADDRESS="$(diagrid project get my-project -o json | jq -r '.status.endpoints.grpc | "\(.host):\(.port)"')"
export TEMPORAL_NAMESPACE=orders
export TEMPORAL_API_KEY="$(diagrid appid get orders -o json | jq -r .status.apiToken)"

Diagrid only accepts encrypted connections. Temporal's SDKs and CLI turn on TLS when an API key is set, so you don't need another setting.

3. Run your workers and clients​

Start your worker and your client as you usually do. Your workflows now run on Diagrid.

Check on them with the Temporal CLI, which reads the same settings:

temporal workflow list

You can also use diagrid workflow list or the Diagrid Web Console.

If your code sets the connection itself​

Code that loads Temporal's environment configuration needs no changes. Temporal's money transfer tutorials do this.

If your code passes a fixed address such as localhost:7233, load the environment configuration instead:

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

client = await Client.connect(**ClientConfig.load_client_connect_config())

These Temporal SDK versions load the environment configuration:

SDKVersionNote
Python1.14 or latertemporalio.envconfig
Go1.32.1 or laterThe contrib/envconfig package
Java1.32.1 or laterA separate artifact. Version 1.32.0 needs a temporal.toml file
TypeScript1.13.2 or later
.NET1.9 or later

Older SDKs have no option for an API key. Pass the App's API token as the header authorization: Bearer <token> on the connection instead, and set the address, the namespace and TLS in your code. You can also do this on a current SDK instead of loading the environment configuration.

Next steps​