class CloudRunIdPlugin(temporalio.plugin.SimplePlugin): (source)
Constructor: CloudRunIdPlugin(metadata, timeout, metadata_url, getenv)
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 |
Fetch Cloud Run metadata and set the client identity before connecting. |
| Method | _resolve |
Return the cached Cloud Run metadata, fetching it once on first use. |
| Instance Variable | _getenv |
Undocumented |
| Instance Variable | _metadata |
Undocumented |
| Instance Variable | _metadata |
Undocumented |
| Instance Variable | _timeout |
Undocumented |
Inherited from SimplePlugin:
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Method | name |
See base class. |
| Async Method | run |
See base class. |
| Async Method | run |
See base class. |
| Instance Variable | activities |
Undocumented |
| Instance Variable | data |
Undocumented |
| Instance Variable | interceptors |
Undocumented |
| Instance Variable | nexus |
Undocumented |
| Instance Variable | run |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflows |
Undocumented |
| Instance Variable | _name |
Undocumented |
GoogleCloudRunMetadata | None = None, timeout: float = 2.0, metadata_url: str = CLOUD_RUN_METADATA_URL, getenv: Callable[ [ str], str | None] = os.environ.get):
(source)
¶
temporalio.plugin.SimplePlugin.__init__Create a Cloud Run plugin.
| Parameters | |
metadata:GoogleCloudRunMetadata | None | Pre-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:float | Timeout, in seconds, for the request to the metadata server. Ignored when metadata is supplied. |
metadatastr | URL of the Cloud Run metadata server endpoint that returns the instance id. Ignored when metadata is supplied. |
getenv:Callable[ | Callable used to look up environment variables. Defaults to os.environ.get and exists primarily for testing. Ignored when metadata is supplied. |
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.