class documentation

Set a Temporal client's identity from Google Cloud Run instance metadata.

Install this plugin once when connecting the client; the identity it sets automatically propagates to workers created from that client. It sets the client identity to a value derived from the Cloud Run instance, but only when the caller did not already provide one. Both Cloud Run worker pools and services are supported.

The Cloud Run instance metadata is fetched once, lazily, when the client connects. If it cannot be read (usually because the process is not running on Cloud Run), connecting raises an error.

Unit tests and advanced callers can bypass the metadata server by passing a pre-built metadata object, or steer the fetch with getenv / metadata_url / timeout.

Warning

Google Cloud Run support is experimental and may change in future versions.

Method __init__ Create a Cloud Run plugin.
Async Method connect_service_client Fetch Cloud Run metadata and set the client identity before connecting.
Method _resolve_metadata Return the cached Cloud Run metadata, fetching it once on first use.
Instance Variable _getenv Undocumented
Instance Variable _metadata Undocumented
Instance Variable _metadata_url Undocumented
Instance Variable _timeout Undocumented

Inherited from SimplePlugin:

Method configure_client See base class.
Method configure_replayer See base class.
Method configure_worker See base class.
Method name See base class.
Async Method run_replayer See base class.
Async Method run_worker See base class.
Instance Variable activities Undocumented
Instance Variable data_converter Undocumented
Instance Variable interceptors Undocumented
Instance Variable nexus_service_handlers Undocumented
Instance Variable run_context Undocumented
Instance Variable workflow_failure_exception_types Undocumented
Instance Variable workflow_runner Undocumented
Instance Variable workflows Undocumented
Instance Variable _name Undocumented
def __init__(self, *, metadata: GoogleCloudRunMetadata | None = None, timeout: float = 2.0, metadata_url: str = CLOUD_RUN_METADATA_URL, getenv: Callable[[str], str | None] = os.environ.get): (source)

Create a Cloud Run plugin.

Parameters
metadata:GoogleCloudRunMetadata | NonePre-fetched Cloud Run instance metadata. When supplied, the plugin uses it directly and never contacts the metadata server. Primarily for testing and advanced use.
timeout:floatTimeout, in seconds, for the request to the metadata server. Ignored when metadata is supplied.
metadata_url:strURL of the Cloud Run metadata server endpoint that returns the instance id. Ignored when metadata is supplied.
getenv:Callable[[str], str | None]Callable used to look up environment variables. Defaults to os.environ.get and exists primarily for testing. Ignored when metadata is supplied.
async def connect_service_client(self, config: ConnectConfig, next: Callable[[ConnectConfig], Awaitable[ServiceClient]]) -> ServiceClient: (source)

Fetch Cloud Run metadata and set the client identity before connecting.

The identity is only set when the caller did not provide one, so an explicit identity passed to temporalio.client.Client.connect always wins.

def _resolve_metadata(self) -> GoogleCloudRunMetadata: (source)

Return the cached Cloud Run metadata, fetching it once on first use.

Undocumented

_metadata = (source)

Undocumented

_metadata_url = (source)

Undocumented

_timeout = (source)

Undocumented