Class: WorkflowClient
testing.WorkflowClient
A client with the exact same API as the "normal" client with 1 exception, When this client waits on a Workflow's result, it will enable time skipping in the test server.
Hierarchy
WorkflowClient
↳
WorkflowClient
Constructors
constructor
• new WorkflowClient(options
)
Parameters
Name | Type |
---|---|
options | WorkflowClientOptions |
Overrides
BaseWorkflowClient.constructor
Properties
connection
• Readonly
connection: ConnectionLike
Inherited from
BaseWorkflowClient.connection
options
• Readonly
options: LoadedWorkflowClientOptions
Inherited from
BaseWorkflowClient.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 to the service.
Returns
WorkflowService
Inherited from
BaseWorkflowClient.workflowService
Methods
execute
▸ execute<T
>(workflowTypeOrFunc
, options
): Promise
<WorkflowResultType
<T
>>
Execute a Workflow and wait for completion.
see
{@link BaseWorkflowClient.execute}
Type parameters
Name | Type |
---|---|
T | extends Workflow |
Parameters
Name | Type |
---|---|
workflowTypeOrFunc | string | T |
options | WorkflowStartOptions <T > |
Returns
Promise
<WorkflowResultType
<T
>>
Overrides
BaseWorkflowClient.execute
getHandle
▸ getHandle<T
>(workflowId
, runId?
, options?
): WorkflowHandle
<T
>
Create a handle to an existing Workflow.
- If only
workflowId
is passed, and there are multiple Workflow Executions with that ID, the handle will refer to the most recent one. - If
workflowId
andrunId
are passed, the handle will refer to the specific Workflow Execution with that Run ID. - If
workflowId
and {@link GetWorkflowHandleOptions.firstExecutionRunId} are passed, the handle will refer to the most recent Workflow Execution in the Chain that started withfirstExecutionRunId
.
A Chain is a series of Workflow Executions that share the same Workflow ID and are connected by:
- Being part of the same Cron
- Continue As New
- Retries
This method does not validate workflowId
. If there is no Workflow Execution with the given workflowId
, handle
methods like handle.describe()
will throw a {@link WorkflowNotFoundError} error.
Type parameters
Name | Type |
---|---|
T | extends Workflow |
Parameters
Name | Type |
---|---|
workflowId | string |
runId? | string |
options? | GetWorkflowHandleOptions |
Returns
WorkflowHandle
<T
>
Inherited from
BaseWorkflowClient.getHandle
result
▸ result<T
>(workflowId
, runId?
, opts?
): Promise
<T
>
Gets the result of a Workflow execution.
see
{@link BaseWorkflowClient.result}
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
workflowId | string |
runId? | string |
opts? | WorkflowResultOptions |
Returns
Promise
<T
>
Overrides
BaseWorkflowClient.result
signalWithStart
▸ signalWithStart<T
, SA
>(workflowTypeOrFunc
, options
): Promise
<WorkflowHandleWithSignaledRunId
<T
>>
Sends a signal to a running Workflow or starts a new one if not already running and immediately signals it. Useful when you're unsure of the Workflows' run state.
Type parameters
Name | Type |
---|---|
T | extends Workflow |
SA | extends any [] = [] |
Parameters
Name | Type |
---|---|
workflowTypeOrFunc | string | T |
options | WithWorkflowArgs <T , WorkflowSignalWithStartOptions <SA >> |
Returns
Promise
<WorkflowHandleWithSignaledRunId
<T
>>
a WorkflowHandle to the started Workflow
Inherited from
BaseWorkflowClient.signalWithStart
start
▸ start<T
>(workflowTypeOrFunc
, options
): Promise
<WorkflowHandleWithFirstExecutionRunId
<T
>>
Start a new Workflow execution.
Type parameters
Name | Type |
---|---|
T | extends Workflow |
Parameters
Name | Type |
---|---|
workflowTypeOrFunc | string | T |
options | WorkflowStartOptions <T > |
Returns
Promise
<WorkflowHandleWithFirstExecutionRunId
<T
>>
a WorkflowHandle to the started Workflow
Inherited from
BaseWorkflowClient.start
withDeadline
▸ withDeadline<R
>(deadline
, fn
): Promise
<R
>
Set the deadline for any service requests executed in fn
's scope.
Type parameters
Name |
---|
R |
Parameters
Name | Type |
---|---|
deadline | number | Date |
fn | () => Promise <R > |
Returns
Promise
<R
>
Inherited from
BaseWorkflowClient.withDeadline
withMetadata
▸ withMetadata<R
>(metadata
, fn
): Promise
<R
>
Set metadata for any service requests executed in fn
's scope.
see
{@link Connection.withMetadata}
Type parameters
Name |
---|
R |
Parameters
Name | Type |
---|---|
metadata | Metadata |
fn | () => Promise <R > |
Returns
Promise
<R
>
returned value of fn
Inherited from
BaseWorkflowClient.withMetadata