public interface ReplayWorkflowContext extends ReplayAware
TODO(maxim): Get rid of any Exceptions in the callbacks. They should only return Failure.
Modifier and Type | Method and Description |
---|---|
void |
continueAsNewOnCompletion(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes attributes) |
long |
currentTimeMillis() |
int |
getAttempt() |
java.util.List<ContextPropagator> |
getContextPropagators() |
io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes |
getContinueAsNewOnCompletion()
When these attributes are present upon completion of the workflow code the ContinueAsNew
command is emitted instead of the workflow completion.
|
java.util.Optional<java.lang.String> |
getContinuedExecutionRunId()
RunId of the first run in the continue-as-new chain.
|
boolean |
getEnableLoggingInReplay() |
io.temporal.api.common.v1.Payload |
getMemo(java.lang.String key) |
com.uber.m3.tally.Scope |
getMetricsScope() |
java.lang.String |
getNamespace()
Workflow namespace.
|
io.temporal.api.common.v1.WorkflowExecution |
getParentWorkflowExecution() |
java.util.Map<java.lang.String,java.lang.Object> |
getPropagatedContexts()
Returns all current contexts being propagated by a
ContextPropagator . |
java.lang.String |
getRunId() |
long |
getRunStartedTimestampMillis() |
io.temporal.api.common.v1.SearchAttributes |
getSearchAttributes()
Used to retrieve search attributes.
|
java.lang.String |
getTaskQueue()
Workflow task queue name.
|
void |
getVersion(java.lang.String changeId,
int minSupported,
int maxSupported,
Functions.Proc2<java.lang.Integer,java.lang.RuntimeException> callback)
GetVersion is used to safely perform backwards incompatible changes to workflow definitions.
|
io.temporal.api.common.v1.WorkflowExecution |
getWorkflowExecution() |
java.time.Duration |
getWorkflowExecutionTimeout() |
java.lang.String |
getWorkflowId() |
java.time.Duration |
getWorkflowRunTimeout() |
java.time.Duration |
getWorkflowTaskTimeout() |
io.temporal.api.common.v1.WorkflowType |
getWorkflowType() |
boolean |
isCancelRequested()
Is cancel of the workflow requested.
|
void |
mutableSideEffect(java.lang.String id,
Functions.Func1<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.util.Optional<io.temporal.api.common.v1.Payloads>> func,
Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
mutableSideEffect is similar to sideEffect in allowing calls of
non-deterministic functions from workflow code. |
java.util.Random |
newRandom()
Replay safe random.
|
Functions.Proc1<java.lang.RuntimeException> |
newTimer(java.time.Duration delay,
Functions.Proc1<java.lang.RuntimeException> callback)
Create a Value that becomes ready after the specified delay.
|
java.util.UUID |
randomUUID() |
void |
requestCancelExternalWorkflowExecution(io.temporal.api.common.v1.WorkflowExecution execution,
Functions.Proc2<java.lang.Void,java.lang.RuntimeException> callback)
Request cancellation of a workflow execution by WorkflowId and optionally RunId.
|
Functions.Proc1<java.lang.Exception> |
scheduleActivityTask(ExecuteActivityParameters parameters,
Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback)
Requests an activity execution.
|
Functions.Proc |
scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters,
Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback) |
void |
sideEffect(Functions.Func<java.util.Optional<io.temporal.api.common.v1.Payloads>> func,
Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
Executes the provided function once, records its result into the workflow history.
|
Functions.Proc1<java.lang.Exception> |
signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes.Builder attributes,
Functions.Proc2<java.lang.Void,io.temporal.api.failure.v1.Failure> callback)
Signal a workflow execution by WorkflowId and optionally RunId.
|
Functions.Proc1<java.lang.Exception> |
startChildWorkflow(StartChildWorkflowExecutionParameters parameters,
Functions.Proc1<io.temporal.api.common.v1.WorkflowExecution> executionCallback,
Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.lang.Exception> callback)
Start child workflow.
|
void |
upsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes searchAttributes)
Updates or inserts search attributes used to index workflows.
|
isReplaying
io.temporal.api.common.v1.WorkflowExecution getWorkflowExecution()
io.temporal.api.common.v1.WorkflowExecution getParentWorkflowExecution()
io.temporal.api.common.v1.WorkflowType getWorkflowType()
boolean isCancelRequested()
io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes getContinueAsNewOnCompletion()
java.util.Optional<java.lang.String> getContinuedExecutionRunId()
java.lang.String getTaskQueue()
java.lang.String getNamespace()
java.lang.String getWorkflowId()
java.lang.String getRunId()
java.time.Duration getWorkflowRunTimeout()
java.time.Duration getWorkflowExecutionTimeout()
long getRunStartedTimestampMillis()
java.time.Duration getWorkflowTaskTimeout()
io.temporal.api.common.v1.Payload getMemo(java.lang.String key)
io.temporal.api.common.v1.SearchAttributes getSearchAttributes()
WorkflowUtils.getValueFromSearchAttributes
to retrieve concrete value.java.util.Map<java.lang.String,java.lang.Object> getPropagatedContexts()
ContextPropagator
. The key is the ContextPropagator.getName()
and the value is the object returned by ContextPropagator.getCurrentContext()
java.util.List<ContextPropagator> getContextPropagators()
Functions.Proc1<java.lang.Exception> scheduleActivityTask(ExecuteActivityParameters parameters, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback)
parameters
- An object which encapsulates all the information required to schedule an
activity for executioncallback
- Callback that is called upon activity completion or failure.Functions.Proc1.apply(Object)
to cancel activity task.Functions.Proc scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback)
Functions.Proc1<java.lang.Exception> startChildWorkflow(StartChildWorkflowExecutionParameters parameters, Functions.Proc1<io.temporal.api.common.v1.WorkflowExecution> executionCallback, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.lang.Exception> callback)
parameters
- An object which encapsulates all the information required to schedule a child
workflow for executioncallback
- Callback that is called upon child workflow completion or failure.Functions.Proc1.apply(Object)
to cancel activity task.Functions.Proc1<java.lang.Exception> signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes.Builder attributes, Functions.Proc2<java.lang.Void,io.temporal.api.failure.v1.Failure> callback)
attributes
- signal informationcallback
- callback notified about the operation resultvoid requestCancelExternalWorkflowExecution(io.temporal.api.common.v1.WorkflowExecution execution, Functions.Proc2<java.lang.Void,java.lang.RuntimeException> callback)
execution
- contains WorkflowId and optional RunId of the workflow to send request to.callback
- callback notified about the operation resultvoid continueAsNewOnCompletion(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes attributes)
long currentTimeMillis()
PollWorkflowTaskQueueResponse
start event of the workflow task
being processed or replayed.Functions.Proc1<java.lang.RuntimeException> newTimer(java.time.Duration delay, Functions.Proc1<java.lang.RuntimeException> callback)
delay
- time-interval after which the Value becomes ready.callback
- Callback that is called with null parameter after the specified delay.
CanceledException is passed as a parameter in case of a cancellation.Functions.Proc1.apply(Object)
to cancel timer.void sideEffect(Functions.Func<java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
Error
which causes workflow task failure. The workflow task after timeout is rescheduled and
re-executed giving SideEffect another chance to succeed. Use scheduleLocalActivityTask(ExecuteLocalActivityParameters, Functions.Proc2)
for executing
operations that rely on non-global dependencies and can fail.func
- function that is called once to return a value.callback
- function that accepts the result of the side effect.void mutableSideEffect(java.lang.String id, Functions.Func1<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
mutableSideEffect
is similar to sideEffect
in allowing calls of
non-deterministic functions from workflow code.
The difference between mutableSideEffect
and sideEffect
is that every new
sideEffect
call in non-replay mode results in a new marker event recorded into the
history. However, mutableSideEffect
only records a new marker if a value has changed.
During the replay, mutableSideEffect
will not execute the function again, but it will
return the exact same value as it was returning during the non-replay run.
One good use case of mutableSideEffect
is to access a dynamically changing config
without breaking determinism. Even if called very frequently the config value is recorded only
when it changes not causing any performance degradation due to a large history size.
Caution: do not use mutableSideEffect
function to modify any workflow state. Only
use the mutableSideEffect's return value.
id
- id of the side effect call. It links multiple calls together. Calls with different
ids are completely independent.func
- function that gets as input a result of a previous mutableSideEffect
call.
The function executes its business logic (like checking config value) and if value didn't
change returns Optional.empty()
. If value has changed and needs to be recorded in
the history then it is returned instead.callback
- function that accepts the result of the mutable side effect which is current or
cached result of the func.void getVersion(java.lang.String changeId, int minSupported, int maxSupported, Functions.Proc2<java.lang.Integer,java.lang.RuntimeException> callback)
changeId
- identifier of a particular changeminSupported
- min version supported for the changemaxSupported
- max version supported for the changecallback
- used to return versionjava.util.Random newRandom()
com.uber.m3.tally.Scope getMetricsScope()
boolean getEnableLoggingInReplay()
java.util.UUID randomUUID()
void upsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes searchAttributes)
int getAttempt()