Skip to content

Add Google Cloud Run worker sample - #219

Draft
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id
Draft

Add Google Cloud Run worker sample#219
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id

Conversation

@seanbollin

Copy link
Copy Markdown

What

Adds a Cloud Run Worker sample (src/CloudRunWorker) showing how to run a long-lived Temporal Worker on Google Cloud Run and derive its identity and Worker Deployment Version from Cloud Run metadata using the new Temporalio.Extensions.Gcp.CloudRun helper.

The sample:

  • Calls TemporalClientConnectOptions.ApplyGoogleCloudRunDefaultsAsync() to read the instance id from the Cloud Run metadata server and the deployment name/revision from the environment, and set the client Identity to {instanceId}@{revision}.
  • Calls TemporalWorkerOptions.ApplyGoogleCloudRunDefaults(metadata) to enable Worker Versioning with a Pinned default behavior, using deployment name = Cloud Run worker pool / service name and build id = Cloud Run revision.
  • Reads TEMPORAL_ADDRESS / TEMPORAL_NAMESPACE / TEMPORAL_TASK_QUEUE from the environment (plaintext connection), registers a greeting workflow + activity, and polls until the container receives SIGTERM.

It mirrors the existing LambdaWorker sample's structure and README style, and its README.md explains Cloud Run worker pools and how to deploy with gcloud run worker-pools deploy ... --set-env-vars ....

Draft: depends on the unreleased helper

Temporalio.Extensions.Gcp.CloudRun is not published to NuGet yet (it is added by the open draft PR on temporalio/sdk-dotnet branch cloud-run-worker-id). So the sample temporarily references the SDK from a sibling checkout via ProjectReference and removes the default Temporalio* package references that Directory.Build.props adds:

temporalio/
  samples-dotnet/     # this repo
  sdk-dotnet-2/       # temporalio/sdk-dotnet @ cloud-run-worker-id

When the package is released, the temporary item groups in TemporalioSamples.CloudRunWorker.csproj should be deleted and replaced with a single <PackageReference Include="Temporalio.Extensions.Gcp.CloudRun" />, and the project can then be added to TemporalioSamples.sln. Both the sample README and the csproj document this. This is why the PR is a draft — CI cannot build the sample from a released package until then.

Because of that, the project is intentionally not added to TemporalioSamples.sln yet, so the repo's dotnet build (solution) stays green.

Testing

Built locally against the sibling sdk-dotnet-2 checkout (dotnet build src/CloudRunWorker): succeeds, 0 warnings / 0 errors, targeting net8.0.

🤖 Generated with Claude Code

Add a long-lived Temporal Worker sample for Google Cloud Run that uses the new
Temporalio.Extensions.Gcp.CloudRun helper to derive the worker identity and a
pinned Worker Deployment Version from Cloud Run metadata. It reads
TEMPORAL_ADDRESS / TEMPORAL_NAMESPACE / TEMPORAL_TASK_QUEUE from the
environment, registers a greeting workflow and activity, and polls until the
container is stopped.

The helper is unreleased, so the project temporarily references the SDK from a
sibling sdk-dotnet checkout via ProjectReference; the README and csproj explain
how to switch to the released package. This is why the PR is a draft.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant