Class: 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.
Extends
Implements
TypedActivityClient<any>
Constructors
Constructor
new ActivityClient(
options?):ActivityClient
Parameters
options?
Returns
ActivityClient
Overrides
AsyncCompletionClient.constructor
Properties
connection
readonlyconnection: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
readonlyoptions:LoadedAsyncCompletionClientOptions
Inherited from
Accessors
workflowService
Get Signature
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
Inherited from
AsyncCompletionClient.workflowService
Methods
complete()
Call Signature
complete(
taskToken,result,options?):Promise<void>
Complete an Activity by task token
Parameters
taskToken
Uint8Array
result
unknown
options?
AsyncCompletionCompleteOptions & AsyncCompletionOperationOptions
Returns
Promise<void>
Inherited from
AsyncCompletionClient.complete
Call Signature
complete(
fullActivityId,result,options?):Promise<void>
Complete an Activity by full ID
Parameters
fullActivityId
result
unknown
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
query
string
Returns
Promise<CountActivityExecutions>
execute()
execute<
R>(activity,options):Promise<R>
Executes a Standalone Activity until completion and returns the result.
Type Parameters
R
R = any
Parameters
activity
string
Name of the activity to start.
options
Options controlling the activity execution.
Returns
Promise<R>
Result of the activity.
Implementation of
fail()
Call Signature
fail(
taskToken,err,options?):Promise<void>
Fail an Activity by task token
Parameters
taskToken
Uint8Array
err
unknown
options?
AsyncCompletionOperationOptions
Returns
Promise<void>
Inherited from
Call Signature
fail(
fullActivityId,err):Promise<void>
Fail an Activity by full ID
Parameters
fullActivityId
err
unknown
Returns
Promise<void>
Inherited from
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
R
R = any
Parameters
activityId
string
ID of the Activity.
runId?
string
Optional run ID of the specific Activity execution.
Returns
Handle to the specified activity execution.
getHandleWithOptions()
Call Signature
getHandleWithOptions<
A>(activityId,options):ActivityHandle<Awaited<ReturnType<A>>>
Creates an Activity handle using options that may include an Activity definition or result TypeInfo.
Type Parameters
A
A extends ActivityFunction<any[], any>
Parameters
activityId
string
ID of the Activity.
options
ActivityHandleDefinitionOptions<A>
Options identifying the Activity run and describing its result type.
Returns
ActivityHandle<Awaited<ReturnType<A>>>
Handle to the specified Activity execution.
Call Signature
getHandleWithOptions<
R>(activityId,options):ActivityHandle<R>
Creates an Activity handle using options that may include an Activity definition or result TypeInfo.
Type Parameters
R
R = any
Parameters
activityId
string
ID of the Activity.
options
Options identifying the Activity run and describing its result type.
Returns
Handle to the specified Activity execution.
heartbeat()
Call Signature
heartbeat(
taskToken,details?,options?):Promise<void>
Send Activity heartbeat by task token
Parameters
taskToken
Uint8Array
details?
unknown
options?
AsyncCompletionOperationOptions
Returns
Promise<void>
Inherited from
AsyncCompletionClient.heartbeat
Call Signature
heartbeat(
fullActivityId,details?):Promise<void>
Send Activity heartbeat by full ID
Parameters
fullActivityId
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
query
string
Returns
AsyncIterable<ActivityExecutionInfo>
reportCancellation()
Call Signature
reportCancellation(
taskToken,details?,options?):Promise<void>
Report Activity cancellation by task token
Parameters
taskToken
Uint8Array
details?
unknown
options?
AsyncCompletionOperationOptions
Returns
Promise<void>
Inherited from
AsyncCompletionClient.reportCancellation
Call Signature
reportCancellation(
fullActivityId,details?):Promise<void>
Report Activity cancellation by full ID
Parameters
fullActivityId
details?
unknown
Returns
Promise<void>
Inherited from
AsyncCompletionClient.reportCancellation
start()
start<
R>(activity,options):Promise<ActivityHandle<R>>
Starts new Standalone Activity execution.
Type Parameters
R
R = any
Parameters
activity
string
Name of the activity to start.
options
Options 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
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
T
T
Activity interface to use for type checking. The returned client can only start activities present in this interface.
Returns
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
R
R
Parameters
abortSignal
AbortSignal
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
R
R
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<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
R
R
Parameters
metadata
fn
() => Promise<R>
Returns
Promise<R>
returned value of fn