Table of Contents

Class TemporalConnection

Namespace
Temporalio.Client
Assembly
Temporalio.dll

Connection to Temporal.

public sealed class TemporalConnection : ITemporalConnection, IBridgeClientProvider
Inheritance
TemporalConnection
Implements
Inherited Members

Remarks

Connections are thread-safe and are encouraged to be reused.

Properties

ApiKey

Gets or sets the current API key.

public string? ApiKey { get; set; }

Property Value

string

Remarks

This is the "Authorization" HTTP header for every call, with "Bearer " prepended. This is only set if the RPC metadata doesn't already have an "Authorization" key. This can be updated which will apply to all future calls the client makes including inside a worker. Setting this value is thread safe. When setting, this will error if the client is not already connected (e.g. a lazy client has not made a call).

Exceptions

InvalidOperationException

Client is not already connected.

BridgeClient

Gets the handle to the connected bridge or null if the connection is not present. This is for internal use only.

public SafeHandle? BridgeClient { get; }

Property Value

SafeHandle

CloudService

Gets the raw cloud service.

public CloudService CloudService { get; }

Property Value

CloudService

Remarks

WARNING: Cloud Operations API and its client are experimental and APIs may change.

IsConnected

Gets a value indicating whether the client is connected. This is always true unless the client is lazy.

public bool IsConnected { get; }

Property Value

bool

OperatorService

Gets the raw operator service.

public OperatorService OperatorService { get; }

Property Value

OperatorService

Options

Gets the options used to create this connection.

public TemporalConnectionOptions Options { get; }

Property Value

TemporalConnectionOptions

RpcMetadata

Gets or sets the current RPC metadata (i.e. the headers).

public IReadOnlyCollection<KeyValuePair<string, string>> RpcMetadata { get; set; }

Property Value

IReadOnlyCollection<KeyValuePair<string, string>>

Remarks

This can be updated which will apply to all future calls the client makes including inside a worker. Setting this value is thread safe. When setting, this will error if the client is not already connected (e.g. a lazy client has not made a call).

Exceptions

InvalidOperationException

Client is not already connected.

TestService

Gets the raw gRPC test service.

public TestService TestService { get; }

Property Value

TestService

Remarks

Only the StartTimeSkippingAsync(WorkflowEnvironmentStartTimeSkippingOptions?) environment has this service implemented.

WorkflowService

Gets the raw workflow service.

public WorkflowService WorkflowService { get; }

Property Value

WorkflowService

Methods

CheckHealthAsync(RpcService?, RpcOptions?)

Check health for the given service type.

public Task<bool> CheckHealthAsync(RpcService? service = null, RpcOptions? options = null)

Parameters

service RpcService

Service type to check health for. Defaults to WorkflowService.

options RpcOptions

RPC options for the check call.

Returns

Task<bool>

True if healthy, false otherwise.

ConnectAsync()

Attempts connect if not already connected. Does nothing if already connected.

public Task ConnectAsync()

Returns

Task

Task for successful connection.

ConnectAsync(TemporalConnectionOptions)

Connect to Temporal.

public static Task<TemporalConnection> ConnectAsync(TemporalConnectionOptions options)

Parameters

options TemporalConnectionOptions

Options for connecting.

Returns

Task<TemporalConnection>

The established connection.

Exceptions

InvalidOperationException

Thrown when cannot successfully connect.

CreateLazy(TemporalConnectionOptions)

Create a client that will connect to Temporal lazily upon first use. If an initial connection fails, it will be retried next time it is needed. Unconnected clients made from lazy connections cannot be used by workers. Note, RpcMetadata cannot be set until a connection is made.

public static TemporalConnection CreateLazy(TemporalConnectionOptions options)

Parameters

options TemporalConnectionOptions

Options for connecting.

Returns

TemporalConnection

The not-yet-connected connection.

~TemporalConnection()

Finalizes an instance of the TemporalConnection class.

protected ~TemporalConnection()