Class TemporalClient
- Namespace
- Temporalio.Client
- Assembly
- Temporalio.dll
Client for a Temporal namespace.
public class TemporalClient : ITemporalClient, IWorkerClient
- Inheritance
-
TemporalClient
- Implements
- Inherited Members
- Extension Methods
Constructors
TemporalClient(ITemporalConnection, TemporalClientOptions)
Initializes a new instance of the TemporalClient class from an existing connection.
public TemporalClient(ITemporalConnection connection, TemporalClientOptions options)
Parameters
connection
ITemporalConnectionConnection for this client.
options
TemporalClientOptionsOptions for this client.
Properties
BridgeClientProvider
Gets the bridge client provider for this client.
public IBridgeClientProvider BridgeClientProvider { get; }
Property Value
Connection
Gets the connection associated with this client.
public ITemporalConnection Connection { get; }
Property Value
Options
Gets the options used to create this client.
public TemporalClientOptions Options { get; }
Property Value
OutboundInterceptor
Gets the outbound interceptor in use.
public ClientOutboundInterceptor OutboundInterceptor { get; }
Property Value
RetryRpcOptions
Gets a fixed set of retry-only RPC options.
protected static RpcOptions RetryRpcOptions { get; }
Property Value
Methods
ConnectAsync(TemporalClientConnectOptions)
Connect to a Temporal namespace.
public static Task<TemporalClient> ConnectAsync(TemporalClientConnectOptions options)
Parameters
options
TemporalClientConnectOptionsOptions for connecting.
Returns
- Task<TemporalClient>
The connected client.
CreateScheduleAsync(string, Schedule, ScheduleOptions?)
Create a schedule and return its handle.
public Task<ScheduleHandle> CreateScheduleAsync(string scheduleID, Schedule schedule, ScheduleOptions? options = null)
Parameters
scheduleID
stringUnique ID for the schedule.
schedule
ScheduleSchedule to create.
options
ScheduleOptionsOptions for creating the schedule.
Returns
- Task<ScheduleHandle>
Handle to the created schedule.
Remarks
This can throw ScheduleAlreadyRunningException if the ID already exists.
DefaultRetryOptions(RpcOptions?)
Get a default set of retry options given the optional options. This will not mutate the given options. This only sets retry if original options are not present or they have not already set a retry.
protected static RpcOptions DefaultRetryOptions(RpcOptions? origOptions)
Parameters
origOptions
RpcOptionsOriginal options to use as a base for the return.
Returns
- RpcOptions
Options with default retry set.
GetAsyncActivityHandle(byte[])
Get a handle to complete an activity asynchronously using its task token.
public AsyncActivityHandle GetAsyncActivityHandle(byte[] taskToken)
Parameters
taskToken
byte[]Task token for the activity.
Returns
- AsyncActivityHandle
Async activity handle.
GetAsyncActivityHandle(string, string, string)
Get a handle to complete an activity asynchronously using its qualified identifiers.
public AsyncActivityHandle GetAsyncActivityHandle(string workflowID, string runID, string activityID)
Parameters
workflowID
stringID for the activity's workflow.
runID
stringRun ID for the activity's workflow.
activityID
stringID for the activity.
Returns
- AsyncActivityHandle
Async activity handle.
GetScheduleHandle(string)
Gets the schedule handle for the given ID.
public ScheduleHandle GetScheduleHandle(string scheduleID)
Parameters
scheduleID
stringSchedule ID to get the handle for.
Returns
- ScheduleHandle
Schedule handle.
GetWorkflowHandle(string, string?, string?)
Get a workflow handle for an existing workflow with unknown return type.
public WorkflowHandle GetWorkflowHandle(string id, string? runID = null, string? firstExecutionRunID = null)
Parameters
id
stringID of the workflow.
runID
stringRun ID of the workflow or null for latest.
firstExecutionRunID
stringOptional first execution ID used for cancellation and termination.
Returns
- WorkflowHandle
Created workflow handle.
GetWorkflowHandle<TWorkflow>(string, string?, string?)
Get a workflow handle for an existing workflow with known type.
public WorkflowHandle<TWorkflow> GetWorkflowHandle<TWorkflow>(string id, string? runID = null, string? firstExecutionRunID = null)
Parameters
id
stringID of the workflow.
runID
stringRun ID of the workflow or null for latest.
firstExecutionRunID
stringOptional first execution ID used for cancellation and termination.
Returns
- WorkflowHandle<TWorkflow>
Created workflow handle.
Type Parameters
TWorkflow
Workflow class type.
GetWorkflowHandle<TWorkflow, TResult>(string, string?, string?)
Get a workflow handle for an existing workflow with known type and return type.
public WorkflowHandle<TWorkflow, TResult> GetWorkflowHandle<TWorkflow, TResult>(string id, string? runID = null, string? firstExecutionRunID = null)
Parameters
id
stringID of the workflow.
runID
stringRun ID of the workflow or null for latest.
firstExecutionRunID
stringOptional first execution ID used for cancellation and termination.
Returns
- WorkflowHandle<TWorkflow, TResult>
Created workflow handle.
Type Parameters
TWorkflow
Workflow class type.
TResult
Result type of the workflow.
ListSchedulesAsync(ScheduleListOptions?)
List schedules.
public IAsyncEnumerable<ScheduleListDescription> ListSchedulesAsync(ScheduleListOptions? options = null)
Parameters
options
ScheduleListOptionsOptions for the list call.
Returns
- IAsyncEnumerable<ScheduleListDescription>
Async enumerator for the schedules.
ListWorkflowsAsync(string, WorkflowListOptions?)
List workflows with the given query.
public IAsyncEnumerable<WorkflowExecution> ListWorkflowsAsync(string query, WorkflowListOptions? options = null)
Parameters
query
stringQuery to use for filtering.
options
WorkflowListOptionsOptions for the list call.
Returns
- IAsyncEnumerable<WorkflowExecution>
Async enumerator for the workflows.
StartWorkflowAsync(string, IReadOnlyCollection<object?>, WorkflowOptions)
Start a workflow by name.
public Task<WorkflowHandle> StartWorkflowAsync(string workflow, IReadOnlyCollection<object?> args, WorkflowOptions options)
Parameters
workflow
stringWorkflow type name.
args
IReadOnlyCollection<object>Arguments for the workflow.
options
WorkflowOptionsStart workflow options. ID and TaskQueue are required.
Returns
- Task<WorkflowHandle>
Workflow handle for the started workflow.
Exceptions
- ArgumentException
Invalid options.
- WorkflowAlreadyStartedException
Workflow was already started according to ID reuse policy.
- RpcException
Server-side error.
StartWorkflowAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowOptions)
Start a workflow via lambda invoking the run method.
public Task<WorkflowHandle<TWorkflow>> StartWorkflowAsync<TWorkflow>(Expression<Func<TWorkflow, Task>> workflowRunCall, WorkflowOptions options)
Parameters
workflowRunCall
Expression<Func<TWorkflow, Task>>Invocation of workflow run method with no result.
options
WorkflowOptionsStart workflow options. ID and TaskQueue are required.
Returns
- Task<WorkflowHandle<TWorkflow>>
Workflow handle for the started workflow.
Type Parameters
TWorkflow
Workflow class type.
Exceptions
- ArgumentException
Invalid run call or options.
- WorkflowAlreadyStartedException
Workflow was already started according to ID reuse policy.
- RpcException
Server-side error.
StartWorkflowAsync<TWorkflow, TResult>(Expression<Func<TWorkflow, Task<TResult>>>, WorkflowOptions)
Start a workflow via lambda invoking the run method.
public Task<WorkflowHandle<TWorkflow, TResult>> StartWorkflowAsync<TWorkflow, TResult>(Expression<Func<TWorkflow, Task<TResult>>> workflowRunCall, WorkflowOptions options)
Parameters
workflowRunCall
Expression<Func<TWorkflow, Task<TResult>>>Invocation of workflow run method with a result.
options
WorkflowOptionsStart workflow options. ID and TaskQueue are required.
Returns
- Task<WorkflowHandle<TWorkflow, TResult>>
Workflow handle for the started workflow.
Type Parameters
TWorkflow
Workflow class type.
TResult
Workflow result type.
Exceptions
- ArgumentException
Invalid run call or options.
- WorkflowAlreadyStartedException
Workflow was already started according to ID reuse policy.
- RpcException
Server-side error.