Skip to main content

Class: ActivityClient

client.ActivityClient

Client for starting and managing Activities, and for asynchronous completion and heartbeating of Activities. Includes all functionality of AsyncCompletionClient.

Typically this client should not be instantiated directly, instead create the high level Client and use Client.activity to interact with Activities.

Hierarchy​

Implements​

Constructors​

constructor​

• new ActivityClient(options?): ActivityClient

Parameters​

NameType
options?ActivityClientOptions

Returns​

ActivityClient

Overrides​

AsyncCompletionClient.constructor

Properties​

connection​

• Readonly connection: ConnectionLike

The underlying connection or NativeConnection | native connection used by this client.

Clients are cheap to create, but connections are expensive. Where it makes sense, a single connection may and should be reused by multiple Clients.

Inherited from​

AsyncCompletionClient.connection


options​

• Readonly options: LoadedAsyncCompletionClientOptions

Inherited from​

AsyncCompletionClient.options

Accessors​

workflowService​

• get workflowService(): WorkflowService

Raw gRPC access to the Temporal service.

NOTE: The namespace provided in options is not automatically set on requests made via this service object.

Returns​

WorkflowService

Inherited from​

AsyncCompletionClient.workflowService

Methods​

complete​

▸ complete(taskToken, result, options?): Promise<void>

Complete an Activity by task token

Parameters​

NameType
taskTokenUint8Array
resultunknown
options?AsyncCompletionCompleteOptions & AsyncCompletionOperationOptions

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.complete

▸ complete(fullActivityId, result, options?): Promise<void>

Complete an Activity by full ID

Parameters​

NameType
fullActivityIdFullActivityId
resultunknown
options?AsyncCompletionCompleteOptions

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.complete


count​

▸ count(query): Promise<CountActivityExecutions>

Return the number of Activity executions matching the given query.

Note that the number of Activity executions returned is approximate and eventually consistent.

More info on the concept of "visibility" and the query syntax on the Temporal documentation site: https://docs.temporal.io/visibility

Parameters​

NameType
querystring

Returns​

Promise<CountActivityExecutions>


execute​

▸ execute<R>(activity, options): Promise<R>

Executes a Standalone Activity until completion and returns the result.

Type parameters​

NameType
Rany

Parameters​

NameTypeDescription
activitystringName of the activity to start.
optionsActivityOptionsOptions controlling the activity execution.

Returns​

Promise<R>

Result of the activity.

Implementation of​

TypedActivityClient.execute


fail​

▸ fail(taskToken, err, options?): Promise<void>

Fail an Activity by task token

Parameters​

NameType
taskTokenUint8Array
errunknown
options?AsyncCompletionOperationOptions

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.fail

▸ fail(fullActivityId, err): Promise<void>

Fail an Activity by full ID

Parameters​

NameType
fullActivityIdFullActivityId
errunknown

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.fail


getHandle​

▸ getHandle<R>(activityId, runId?): ActivityHandle<R>

Creates an Activity handle from ID and optionally from run ID. If runId is not set, the handle will refer to the newest Activity run with the given Activity ID.

Note 1: this function always succeeds. If the provided ID is invalid, an error will only be thrown when calling the handle's methods.

Note 2: if runID is not set when calling getHandle, then runId property of the returned handle will always remain unset, even after method calls are performed. To get the run ID of the targeted activity execution, call ActivityHandle.describe and read the activityRunId field of the returned ActivityExecutionDescription.

Type parameters​

NameType
Rany

Parameters​

NameTypeDescription
activityIdstringID of the Activity.
runId?stringOptional run ID of the specific Activity execution.

Returns​

ActivityHandle<R>

Handle to the specified activity execution.


getHandleWithOptions​

▸ getHandleWithOptions<R>(activityId, options): ActivityHandle<R>

Creates an Activity handle using options that may include result TypeInfo.

Type parameters​

NameType
Rany

Parameters​

NameTypeDescription
activityIdstringID of the Activity.
optionsGetActivityHandleOptionsOptions identifying the Activity run and describing its result type.

Returns​

ActivityHandle<R>

Handle to the specified Activity execution.


heartbeat​

▸ heartbeat(taskToken, details?, options?): Promise<void>

Send Activity heartbeat by task token

Parameters​

NameType
taskTokenUint8Array
details?unknown
options?AsyncCompletionOperationOptions

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.heartbeat

▸ heartbeat(fullActivityId, details?): Promise<void>

Send Activity heartbeat by full ID

Parameters​

NameType
fullActivityIdFullActivityId
details?unknown

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.heartbeat


list​

▸ list(query): AsyncIterable<ActivityExecutionInfo>

Return a list of Activity executions matching the given query.

Note that the list of Activity executions returned is approximate and eventually consistent.

More info on the concept of "visibility" and the query syntax on the Temporal documentation site: https://docs.temporal.io/visibility

Parameters​

NameType
querystring

Returns​

AsyncIterable<ActivityExecutionInfo>


reportCancellation​

▸ reportCancellation(taskToken, details?, options?): Promise<void>

Report Activity cancellation by task token

Parameters​

NameType
taskTokenUint8Array
details?unknown
options?AsyncCompletionOperationOptions

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.reportCancellation

▸ reportCancellation(fullActivityId, details?): Promise<void>

Report Activity cancellation by full ID

Parameters​

NameType
fullActivityIdFullActivityId
details?unknown

Returns​

Promise<void>

Inherited from​

AsyncCompletionClient.reportCancellation


start​

▸ start<R>(activity, options): Promise<ActivityHandle<R>>

Starts new Standalone Activity execution.

Type parameters​

NameType
Rany

Parameters​

NameTypeDescription
activitystringName of the activity to start.
optionsActivityOptionsOptions controlling the start and execution of the activity.

Returns​

Promise<ActivityHandle<R>>

Handle to the started activity. The handle's runId property will be set to the started run.

Implementation of​

TypedActivityClient.start


typed​

▸ typed<T>(): TypedActivityClient<T>

Returns this client as a TypedActivityClient. It enables strong type checking of Activity name, arguments and result based on the provided Activity interface. Note that no new client object is created - this method only affects type annotations.

Type parameters​

NameDescription
TActivity interface to use for type checking. The returned client can only start activities present in this interface.

Returns​

TypedActivityClient<T>


withAbortSignal​

▸ withAbortSignal<R>(abortSignal, fn): Promise<R>

Set an AbortSignal that, when aborted, cancels any ongoing service requests executed in fn's scope. This will locally result in the request call throwing a _grpc.ServiceError|ServiceError with code _grpc.status.CANCELLED|CANCELLED; see isGrpcCancelledError.

This method is only a convenience wrapper around Connection.withAbortSignal.

Type parameters​

Name
R

Parameters​

NameType
abortSignalAbortSignal
fn() => Promise<R>

Returns​

Promise<R>

value returned from fn

See

https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

Inherited from​

AsyncCompletionClient.withAbortSignal


withDeadline​

▸ withDeadline<R>(deadline, fn): Promise<R>

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.

This method is only a convenience wrapper around Connection.withDeadline.

Type parameters​

Name
R

Parameters​

NameTypeDescription
deadlinenumber | Datea 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<R>-

Returns​

Promise<R>

the value returned from fn

See

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

Inherited from​

AsyncCompletionClient.withDeadline


withMetadata​

▸ withMetadata<R>(metadata, fn): Promise<R>

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

This method is only a convenience wrapper around Connection.withMetadata.

Type parameters​

Name
R

Parameters​

NameType
metadataMetadata
fn() => Promise<R>

Returns​

Promise<R>

returned value of fn

Inherited from​

AsyncCompletionClient.withMetadata