Skip to content

Add Google Cloud Run worker-identity sample - #219

Draft
seanbollin wants to merge 6 commits into
mainfrom
cloud-run-worker-id
Draft

seanbollin wants to merge 6 commits into
mainfrom
cloud-run-worker-id

Conversation

@seanbollin

@seanbollin seanbollin commented Aug 25, 2026

Copy link
Copy Markdown

What

Runnable Google Cloud Run worker-identity sample, laid out under src/Gcp/CloudRun/WorkerId to match the sibling OpenTelemetry Cloud Run sample (src/Gcp/CloudRun/OpenTelemetry).

It registers a single WorkerIdPlugin on TemporalClientConnectOptions.Plugins so the worker identity ({instanceId}@{revision}) is derived from Cloud Run instance metadata and applied to the client, and to every worker created from it. Program.cs also reads GoogleCloudRunMetadata directly and logs its WorkerIdentity. A greeting workflow + activity and a SIGTERM-aware worker loop demonstrate a normal long-lived worker on a Cloud Run worker pool; the workflow is started with the Temporal CLI. No Worker Deployment Versioning — identity only.

Draft: depends on the unreleased helper

Temporalio.Extensions.Gcp.CloudRun.WorkerId is not published to NuGet yet (it is added by the open draft PR on temporalio/sdk-dotnet branch cloud-run-worker-id). While it is unreleased 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, replace the temporary item groups in TemporalioSamples.Gcp.CloudRun.WorkerId.csproj with a single <PackageReference Include="Temporalio.Extensions.Gcp.CloudRun.WorkerId" />. This is why the PR is a draft. The README and csproj document this.

Run

Deploy to a Cloud Run worker pool, then start the greeting workflow with the Temporal CLI — see src/Gcp/CloudRun/WorkerId/README.md.

Testing

  • dotnet build src/Gcp/CloudRun/WorkerId/TemporalioSamples.Gcp.CloudRun.WorkerId.csproj — succeeds, 0 warnings / 0 errors, targeting net8.0.
  • dotnet format --verify-no-changes — clean.

🤖 Generated with Claude Code

seanbollin and others added 5 commits August 25, 2026 13:55
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 <noreply@anthropic.com>
Register a single CloudRunPlugin on TemporalClientConnectOptions.Plugins
instead of calling the removed ApplyGoogleCloudRunDefaults* helpers. The
plugin sets the client identity at connect time and pins the worker to
the Cloud Run deployment version automatically.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Follows the sdk-dotnet rename: the Cloud Run worker-identity plugin is now
WorkerIdPlugin (Cloud Run can host multiple Temporal plugins, so the generic
CloudRunPlugin name is no longer used). Update the sample's registration,
workflow comment, and README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Google Cloud Run worker-ID plugin moved from the root Temporalio.Extensions.Gcp.CloudRun project into a new Temporalio.Extensions.Gcp.CloudRun.WorkerId sibling. Update the project reference, the using directive, and the README to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move src/CloudRunWorker to src/Gcp/CloudRun/WorkerId to mirror the sibling
OpenTelemetry Cloud Run sample, and rename the project and namespace to
TemporalioSamples.Gcp.CloudRun.WorkerId. Register the moved project in the
solution and update the root README sample entry.

Remove all Worker Deployment Versioning content (deployment name, build id,
versioning behavior, pinned) from the code, comments, and README. The sample
now only registers WorkerIdPlugin to set the worker identity from Cloud Run
metadata, and logs GoogleCloudRunMetadata.WorkerIdentity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@seanbollin seanbollin changed the title Add Google Cloud Run worker sample Add Google Cloud Run worker-identity sample Sep 9, 2026
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.

2 participants