Skip to content

Add Cloud Run worker sample (worker identity + deployment versioning) - #795

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

Add Cloud Run worker sample (worker identity + deployment versioning)#795
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id

Conversation

@seanbollin

Copy link
Copy Markdown

What

Adds a runnable Temporal Java worker sample for a Google Cloud Run worker pool in
cloud-run-worker-id/. It uses the new io.temporal:temporal-gcp-cloud-run helper
(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 is fine), registers a small greeting workflow +
activity, and runs until SIGTERM.

It mirrors the existing lambda-worker sample's layout and README style, and includes a Dockerfile
and gcloud run worker-pools deploy … --set-env-vars … instructions for Cloud Run worker pools.

Why draft

The sample depends on io.temporal:temporal-gcp-cloud-run, which is not yet released (SDK PR:
temporalio/sdk-java#3028). Until it ships, settings.gradle wires the sample against a local
Temporal Java SDK checkout via a Gradle composite build (includeBuild), defaulting to a sibling
../sdk-java-2 checkout and overridable with -PtemporalSdkPath=/path/to/sdk-java. The composite
build is skipped when that checkout is absent, so the other samples still build. Once the module is
released, drop the composite-build block from settings.gradle and bump javaSDKVersion in the
samples root build.gradle, then take this PR out of draft.

Files

  • cloud-run-worker-id/src/main/java/.../CloudRunWorker.java — long-lived worker using the helper.
  • GreetingWorkflow[Impl] + GreetingActivities[Impl] — sample workflow/activity; the workflow is
    @WorkflowVersioningBehavior(PINNED) to match the worker's PINNED default.
  • GreetingWorkflowTest.javaTestWorkflowRule unit test (needs neither Cloud Run nor a Service).
  • Dockerfile, README.md, and the settings.gradle composite-build wiring.

Testing

Gradle can't run in this environment (JDK 25 only; the repo's Gradle can't run on it), so the sample
was verified by javac-compiling all sources (--release 17 -Xlint:all, clean) against the real
GoogleCloudRunMetadata plus minimal stubs for the SDK types used, and by symbol-checking every SDK
call against the SDK sources. CI (or a local JDK 21) will run the actual Gradle build and test.

🤖 Generated with Claude Code

…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>
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