Add Google Cloud Run worker-identity sample - #795
Draft
seanbollin wants to merge 5 commits into
Draft
Conversation
…oning Add a runnable Temporal Java worker sample for a Google Cloud Run worker pool. It uses io.temporal:temporal-gcp-cloud-run's GoogleCloudRunMetadata to derive the worker identity and a PINNED Worker Deployment Version from Cloud Run instance metadata, reads TEMPORAL_ADDRESS / TEMPORAL_NAMESPACE / TEMPORAL_TASK_QUEUE (plaintext connection), registers a small greeting workflow and activity, and runs until SIGTERM. Mirrors the lambda-worker sample's layout and README style, with a Dockerfile and gcloud worker-pools deploy instructions. temporal-gcp-cloud-run is not yet released, so settings.gradle wires the sample against a local SDK checkout with a Gradle composite build, defaulting to ../sdk-java-2 and overridable with -PtemporalSdkPath. This is temporary until the module is released; the PR stays a draft until then. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Register CloudRunPlugin on the workflow client instead of calling the removed GoogleCloudRunMetadata.applyTo(...) overloads. The metadata is still fetched once at startup (so the sample can log the identity, deployment name, and build id) and handed to the plugin, which sets the client identity and each worker's PINNED deployment version as it propagates from the client to its workers. The worker no longer needs per-worker WorkerOptions. README updated to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The temporal-gcp-cloud-run module renamed CloudRunPlugin to WorkerIdPlugin (Cloud Run can host multiple plugins in that module), so update the sample worker and its README to construct WorkerIdPlugin. Import ordering is adjusted to keep google-java-format's spotlessCheck clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror the sibling OpenTelemetry sample's gcp/cloud-run/opentelemetry layout: move cloud-run-worker-id/ to gcp/cloud-run/workerid/, rename the Java package io.temporal.samples.cloudrunworkerid to io.temporal.samples.gcp.cloudrun.workerid, and register the module as gcp:cloud-run:workerid in settings.gradle. The worker-identity plugin is now identity-only. Depend on the split-out temporal-gcp-cloud-run-worker-id module (package io.temporal.gcp.cloudrun.workerid), register WorkerIdPlugin, log only the derived identity and task queue, and drop the stale worker-deployment-versioning references from the sample sources and README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Runnable Google Cloud Run worker-identity sample, laid out under
gcp/cloud-run/workerid/tomatch the sibling OpenTelemetry Cloud Run sample (
gcp/cloud-run/opentelemetry/). It registersWorkerIdPluginfromio.temporal:temporal-gcp-cloud-run-worker-idon the client so the workeridentity (
{instanceId}@{revision}) is set from Cloud Run instance metadata; a small greetingworkflow/activity runs on a normal long-lived worker on a Cloud Run worker pool, started with the
Temporal CLI. No Worker Deployment Versioning — identity only.
Why draft
The sample depends on
io.temporal:temporal-gcp-cloud-run-worker-id, which is not yet released.Until it ships,
settings.gradlewires the sample against a local Temporal Java SDK checkout via aGradle composite build (
includeBuild), defaulting to a sibling../sdk-java-2checkout andoverridable with
-PtemporalSdkPath=/path/to/sdk-java. The composite build is skipped when thatcheckout is absent, so the other samples still build. Once the module is released, drop the
composite-build block from
settings.gradleand bumpjavaSDKVersionin the samples rootbuild.gradle, then take this PR out of draft.Run
./gradlew :gcp:cloud-run:workerid:testfor the unit test, then./gradlew -PtemporalSdkPath=/path/to/sdk-java :gcp:cloud-run:workerid:installDistto build therunnable worker; see
gcp/cloud-run/workerid/README.mdfor the Cloud Run worker-pool deploy andtemporal workflow startsteps.🤖 Generated with Claude Code