Documentation

WorkflowStubInterface extends WorkflowRunInterface

WorkflowStub is a client side stub to a single workflow instance.

It can be used to start, signal, query, wait for completion and cancel a workflow execution. Created through WorkflowClient::newUntypedWorkflowStub().

Table of Contents

Methods

cancel()  : void
Request cancellation of a workflow execution.
describe()  : WorkflowExecutionDescription
getExecution()  : WorkflowExecution
Get associated workflow execution (if any).
getOptions()  : WorkflowOptions|null
Returns associated workflow options. Empty for running workflows. Workflow options are immutable and can not be changed after the workflow was created.
getResult()  : mixed
Returns workflow result potentially waiting for workflow to complete.
getUpdateHandle()  : UpdateHandle
Get a handle to an existing update request.
getWorkflowType()  : string|null
hasExecution()  : bool
Check if workflow was started and has associated execution.
query()  : ValuesInterface|null
Synchronously queries workflow by invoking its query handler.
setExecution()  : void
Attaches running workflow context to the workflow stub.
signal()  : void
Sends named signal to the workflow execution.
startUpdate()  : UpdateHandle
Update a workflow execution by invoking its update handler and returning a handle to the update request.
terminate()  : void
Terminates a workflow execution.
update()  : ValuesInterface|null
Synchronously update a workflow execution by invoking its update handler.

Methods

cancel()

Request cancellation of a workflow execution.

public cancel() : void

Cancellation cancels CancellationScopeInterface that wraps the main workflow method. Note that workflow can take long time to get canceled or even completely ignore the cancellation request.

describe()

public describe() : WorkflowExecutionDescription
Return values
WorkflowExecutionDescription

getOptions()

Returns associated workflow options. Empty for running workflows. Workflow options are immutable and can not be changed after the workflow was created.

public getOptions() : WorkflowOptions|null
Return values
WorkflowOptions|null

getResult()

Returns workflow result potentially waiting for workflow to complete.

public getResult([string|ReflectionClass|ReflectionType|Type|null $type = null ][, int|null $timeout = null ]) : mixed

Behind the scene this call performs long poll on Temporal service waiting for workflow completion notification.

// Map to array
$result = $run->getResult(Type::TYPE_ARRAY);

// Map to list of custom class
$result = $run->getResult(Type::arrayOf(Message::class));
Parameters
$type : string|ReflectionClass|ReflectionType|Type|null = null
$timeout : int|null = null

Timeout in seconds. Infinite by the default.

Tags
throws
WorkflowFailedException
see
DateInterval

getUpdateHandle()

Get a handle to an existing update request.

public getUpdateHandle(non-empty-string $updateId[, string|ReflectionClass|ReflectionType|Type|null $resultType = null ]) : UpdateHandle
Parameters
$updateId : non-empty-string
$resultType : string|ReflectionClass|ReflectionType|Type|null = null
Return values
UpdateHandle

hasExecution()

Check if workflow was started and has associated execution.

public hasExecution() : bool
Return values
bool

signal()

Sends named signal to the workflow execution.

public signal(string $name, mixed ...$args) : void
Parameters
$name : string
$args : mixed

startUpdate()

Update a workflow execution by invoking its update handler and returning a handle to the update request.

public startUpdate(non-empty-string|UpdateOptions $nameOrOptions, mixed ...$args) : UpdateHandle

By default, WaitPolicy is set to LifecycleStage::StageAccepted, which means that the handle will return immediately after successful validation of the Update call. However, also note that the processing Workflow worker must be available. Otherwise, the request may block indefinitely or fail due to a timeout.

Usually an update handler is a method annotated with the UpdateMethod attribute.

Parameters
$nameOrOptions : non-empty-string|UpdateOptions

Name of the update handler or update options.

$args : mixed

Arguments to pass to the update handler.

Tags
throws
WorkflowUpdateRPCTimeoutOrCanceledException
Return values
UpdateHandle

terminate()

Terminates a workflow execution.

public terminate(string $reason[, array<string|int, mixed> $details = [] ]) : void

Termination is a hard stop of a workflow execution which doesn't give workflow code any chance to perform cleanup.

Parameters
$reason : string
$details : array<string|int, mixed> = []

update()

Synchronously update a workflow execution by invoking its update handler.

public update(non-empty-string $name, mixed ...$args) : ValuesInterface|null

Usually an update handler is a method annotated with the UpdateMethod attribute.

Parameters
$name : non-empty-string

Name of the update handler.

$args : mixed

Arguments to pass to the update handler.

Tags
throws
WorkflowUpdateException
throws
WorkflowUpdateRPCTimeoutOrCanceledException
Return values
ValuesInterface|null

        
On this page

Search results