Skip to main content

Class: CloudOperationsConnection

Experimental

Client connection to the Temporal Cloud Operations Service endpoint.

⚠️ Connections are expensive to construct and should be reused. Make sure to close any unused connections to avoid leaking resources.

The Temporal Cloud Operations Client API is an experimental feature and may be subject to change.

Properties​

cloudService​

readonly cloudService: CloudService

Experimental

Raw gRPC access to the Temporal Cloud's Operator Service.

The Temporal Cloud Operator Service API defines how Temporal SDKs and other clients interact with the Temporal Cloud platform to perform administrative functions like registering a search attribute or a namespace.

This Service API is NOT compatible with self-hosted Temporal deployments.


healthService​

readonly healthService: Health

Experimental

Raw gRPC access to the standard gRPC health service.


options​

readonly options: ResolvedCloudOperationsConnectionOptions

Experimental

Methods​

close()​

close(): void

Experimental

Close the underlying gRPC client.

Make sure to call this method to ensure proper resource cleanup.

Returns​

void


setApiKey()​

setApiKey(apiKey): void

Experimental

Set the ConnectionOptions.apiKey for all subsequent requests. A static string or a callback function may be provided.

Parameters​

apiKey​

string | (() => string)

Returns​

void


withAbortSignal()​

withAbortSignal<ReturnType>(abortSignal, fn): Promise<ReturnType>

Experimental

Set an `AbortSignal` that, when aborted, cancels any ongoing requests executed in fn's scope.

Type Parameters​

ReturnType​

ReturnType

Parameters​

abortSignal​

AbortSignal

fn​

() => Promise<ReturnType>

Returns​

Promise<ReturnType>

value returned from fn

Example​

const ctrl = new AbortController();
setTimeout(() => ctrl.abort(), 10_000);
// 👇 throws if incomplete by the timeout.
await conn.withAbortSignal(ctrl.signal, () => client.cloudService.someOperation(...));

withApiKey()​

withApiKey<ReturnType>(apiKey, fn): Promise<ReturnType>

Experimental

Set the apiKey for any service requests executed in fn's scope (thus changing the Authorization header).

Type Parameters​

ReturnType​

ReturnType

Parameters​

apiKey​

string

fn​

() => Promise<ReturnType>

Returns​

Promise<ReturnType>

value returned from fn

Example​

const workflowHandle = await conn.withApiKey('secret', () =>
conn.withMetadata({ otherKey: 'set' }, () => client.start(options)))
);

withDeadline()​

withDeadline<ReturnType>(deadline, fn): Promise<ReturnType>

Experimental

Set a deadline for any service requests executed in fn's scope.

The deadline is a point in time after which any pending gRPC request will be considered as failed; this will locally result in the request call throwing a grpc.ServiceError|ServiceError with code grpc.status.DEADLINE_EXCEEDED|DEADLINE_EXCEEDED; see isGrpcDeadlineError.

It is stronly recommended to explicitly set deadlines. If no deadline is set, then it is possible for the client to end up waiting forever for a response.

Type Parameters​

ReturnType​

ReturnType

Parameters​

deadline​

number | Date

a point in time after which the request will be considered as failed; either a Date object, or a number of milliseconds since the Unix epoch (UTC).

fn​

() => Promise<ReturnType>

Returns​

Promise<ReturnType>

the value returned from fn

See​

https://grpc.io/docs/guides/deadlines/


withMetadata()​

withMetadata<ReturnType>(metadata, fn): Promise<ReturnType>

Experimental

Set metadata for any service requests executed in fn's scope.

The provided metadata is merged on top of any existing metadata in current scope.

Type Parameters​

ReturnType​

ReturnType

Parameters​

metadata​

Metadata

fn​

() => Promise<ReturnType>

Returns​

Promise<ReturnType>

value returned from fn

Example​

const result = await conn.withMetadata({ someMetadata: 'value' }, () =>
conn.withMetadata({ otherKey: 'set' }, () => client.cloudService.someOperation(...)))
);

connect()​

static connect(options): Promise<CloudOperationsConnection>

Experimental

Establish a connection with the server and return a CloudOperationsConnection instance.

This is the preferred method of creating connections as it verifies connectivity.

Parameters​

options​

CloudOperationsConnectionOptions

Returns​

Promise<CloudOperationsConnection>


lazy()​

static lazy(options): CloudOperationsConnection

Experimental

Create a lazy CloudOperationsConnection instance.

This method does not verify connectivity with the server. We recommend using connect instead.

Parameters​

options​

CloudOperationsConnectionOptions

Returns​

CloudOperationsConnection