ZWorkflow

zio.temporal.workflow.ZWorkflow$

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ZWorkflow.type

Members list

Value members

Concrete methods

def awaitUntil(cond: => Boolean): Unit

Suspends workflow execution until the given predicate holds

Suspends workflow execution until the given predicate holds

Value parameters

cond

await condition

Attributes

Returns

unblocks when condition becomes true

See also

Workflow.await

def awaitUntil(timeout: Duration)(cond: => Boolean): Boolean

Suspends workflow execution until either the given predicate holds or timeout elapsed

Suspends workflow execution until either the given predicate holds or timeout elapsed

Value parameters

cond

await condition

timeout

await timeout

Attributes

Returns

unblocks when condition becomes true or timeout elapsed. '''False''' if timed out

See also

Workflow.await

def awaitWhile(cond: => Boolean): Unit

Suspends workflow execution while the given predicate holds

Suspends workflow execution while the given predicate holds

Value parameters

cond

await condition

Attributes

Returns

unblocks when condition becomes false

See also

Workflow.await

def awaitWhile(timeout: Duration)(cond: => Boolean): Boolean

Suspends workflow execution while either the given predicate holds or timeout elapsed

Suspends workflow execution while either the given predicate holds or timeout elapsed

Value parameters

cond

await condition

timeout

await timeout

Attributes

Returns

unblocks when condition becomes false or timeout elapsed. '''False''' if timed out

See also

Workflow.await

def continueAsNew(workflowType: String, options: Option[ContinueAsNewOptions], args: Any*): Unit

Continues the current workflow execution as a new run possibly overriding the workflow type and options.

Continues the current workflow execution as a new run possibly overriding the workflow type and options.

Value parameters

args

arguments of the next run.

options

option overrides for the next run, can be null if no overrides are needed

workflowType

workflow type override for the next run, can be null of no override is needed

Attributes

Returns current timestamp

Returns current timestamp

Should be used instead of java.lang.System.currentTimeMillis() to guarantee determinism

Attributes

Returns

current time millis as ZCurrentTimeMillis

See also

Workflow.currentTimeMillis()

GetLastCompletionResult extract last completion result from previous run for this cron workflow. This is used in combination with cron schedule. A workflow can be started with an optional cron schedule. If a cron workflow wants to pass some data to next schedule, it can return any data and that data will become available when next run starts.

GetLastCompletionResult extract last completion result from previous run for this cron workflow. This is used in combination with cron schedule. A workflow can be started with an optional cron schedule. If a cron workflow wants to pass some data to next schedule, it can return any data and that data will become available when next run starts.

Type parameters

R

type of the return data from last run

Attributes

Returns

result of last run

See also

io.temporal.client.WorkflowOptions.Builder#setCronSchedule(String)

def getLogger(name: String): Logger

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

Value parameters

name

name to appear in logging.

Attributes

Returns

logger to use in workflow logic.

def getLogger(clazz: Class[_]): Logger

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

Value parameters

clazz

class name to appear in logging.

Attributes

Returns

logger to use in workflow logic.

def getPreviousRunFailure: Option[Exception]

Extract the latest failure from a previous run of this workflow. If any previous run of this workflow has failed, this function returns that failure. If no previous runs have failed, an empty optional is returned. The run you are calling this from may have been created as a retry of the previous failed run or as a next cron invocation for cron workflows.

Extract the latest failure from a previous run of this workflow. If any previous run of this workflow has failed, this function returns that failure. If no previous runs have failed, an empty optional is returned. The run you are calling this from may have been created as a retry of the previous failed run or as a next cron invocation for cron workflows.

Attributes

Returns

The last Exceptionthat occurred in this workflow, if there has been one.

Retrieves workflow info

Retrieves workflow info

Attributes

Returns

ZWorkflowInfo

See also

io.temporal.workflow.WorkflowInfo

def mutableSideEffect[R](id: String, updated: (R, R) => Boolean, f: () => R)(implicit javaTypeTag: JavaTypeTag[R]): R

mutableSideEffect is similar to sideEffect in allowing calls of non-deterministic functions from workflow code.

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.

If function throws any exception it is not delivered to the workflow code. It is wrapped in Error causing failure of the current workflow task.

Type parameters

R

side effect result type

Value parameters

f

function that produces a value. This function can contain non-deterministic code.

id

unique identifier of this side effect

updated

used to decide if a new value should be recorded. A func result is recorded only if call to updated with stored and a new value as arguments returns true. It is not called for the first value.

Attributes

See also

Creates a builder of client stub to activities that implement given interface.

Creates a builder of client stub to activities that implement given interface.

Type parameters

A

activity interface

Attributes

Returns

activity stub builder

Wraps a procedure in a CancellationScope. The procedure receives the wrapping CancellationScope as a parameter. Useful when cancellation is requested from within the wrapped code. The following example cancels the sibling activity on any failure.

Wraps a procedure in a CancellationScope. The procedure receives the wrapping CancellationScope as a parameter. Useful when cancellation is requested from within the wrapped code. The following example cancels the sibling activity on any failure.

Value parameters

thunk

code to wrap in the cancellation scope

Attributes

Returns

wrapped proc

See also

Workflow.newCancellationScope

Wraps a procedure in a CancellationScope. The procedure receives the wrapping CancellationScope as a parameter. Useful when cancellation is requested from within the wrapped code. The following example cancels the sibling activity on any failure.

Wraps a procedure in a CancellationScope. The procedure receives the wrapping CancellationScope as a parameter. Useful when cancellation is requested from within the wrapped code. The following example cancels the sibling activity on any failure.

Value parameters

thunk

code to wrap in the cancellation scope

Attributes

Returns

wrapped proc

See also

Workflow.newCancellationScope

Creates a builder of client stub that can be used to start a child workflow that implements given interface.

Creates a builder of client stub that can be used to start a child workflow that implements given interface.

Type parameters

A

workflow interface

Attributes

Returns

child workflow stub builder

Creates a client stub that can be used to continue this workflow as a new run.

Creates a client stub that can be used to continue this workflow as a new run.

Type parameters

A

an interface type implemented by the next run of the workflow

Attributes

Creates a CancellationScope that is not linked to a parent scope. ZCancellationScope.run must be called to execute the code the scope wraps. The detached scope is needed to execute cleanup code after a workflow is canceled which cancels the root scope that wraps the @WorkflowMethod invocation. Here is an example usage:

Creates a CancellationScope that is not linked to a parent scope. ZCancellationScope.run must be called to execute the code the scope wraps. The detached scope is needed to execute cleanup code after a workflow is canceled which cancels the root scope that wraps the @WorkflowMethod invocation. Here is an example usage:

Value parameters

thunk

parameter to wrap in a cancellation scope.

Attributes

Returns

wrapped parameter.

See also

Workflow.newDetachedCancellationScope

def newExternalWorkflowStub[A : IsWorkflow](workflowId: String): Of[A]

Creates client stub that can be used to signal or cancel an existing workflow

Creates client stub that can be used to signal or cancel an existing workflow

Type parameters

A

workflow interface

Value parameters

workflowId

id of the workflow to communicate with.

Attributes

Returns

external workflow stub

def newExternalWorkflowStub[A : IsWorkflow](workflowExecution: ZWorkflowExecution): Of[A]

Creates client stub that can be used to signal or cancel an existing workflow

Creates client stub that can be used to signal or cancel an existing workflow

Type parameters

A

workflow interface

Value parameters

workflowExecution

execution of the workflow to communicate with.

Attributes

Returns

external workflow stub

Creates a builder of client stub to local activities that implement given interface.

Creates a builder of client stub to local activities that implement given interface.

Type parameters

A

activity interface

Attributes

Returns

local activity stub builder

def newRandom: Random

Replay safe random numbers generator. Seeded differently for each workflow instance.

Replay safe random numbers generator. Seeded differently for each workflow instance.

Attributes

def newTimer(delay: Duration): ZAsync[Unit]

Create new timer. Note that Temporal service time resolution is in seconds. So all durations are rounded up to the nearest second.

Create new timer. Note that Temporal service time resolution is in seconds. So all durations are rounded up to the nearest second.

Attributes

Returns

ZAsync that becomes ready when at least specified number of seconds passes. It is failed with zio.temporal.failure.CanceledFailure if enclosing scope is canceled.

Creates a builder of untyped client stub to activities

Creates a builder of untyped client stub to activities

Attributes

Returns

untyped activity stub builder

def newUntypedChildWorkflowStub(workflowType: String): Untyped

Creates a builder of untyped client stub that can be used to start a child workflow that implements given interface.

Creates a builder of untyped client stub that can be used to start a child workflow that implements given interface.

Attributes

Returns

child workflow stub builder

def newUntypedExternalWorkflowStub(workflowId: String): Untyped

Creates untyped client stub that can be used to signal or cancel an existing workflow

Creates untyped client stub that can be used to signal or cancel an existing workflow

Value parameters

workflowId

id of the workflow to communicate with.

Attributes

Returns

external workflow stub

Creates untyped client stub that can be used to signal or cancel an existing workflow

Creates untyped client stub that can be used to signal or cancel an existing workflow

Value parameters

workflowExecution

execution of the workflow to communicate with.

Attributes

Returns

external workflow stub

Creates a builder of untyped client stub to local activities that implement given interface.

Creates a builder of untyped client stub to local activities that implement given interface.

Attributes

Returns

local activity stub builder

def randomUUID: UUID

Generated random UUID

Generated random UUID

Should be used instead of UUID.randomUUID() to guarantee determinism

Attributes

Returns

generated UUID

See also

Workflow.randomUUID()

def sideEffect[R](f: () => R)(implicit javaTypeTag: JavaTypeTag[R]): R

Executes the provided function once, records its result into the workflow history. The recorded result on history will be returned without executing the provided function during replay. This guarantees the deterministic requirement for workflow as the exact same result will be returned in replay. Common use case is to run some short non-deterministic code in workflow, like getting random number. The only way to fail SideEffect is to panic which causes workflow task failure. The workflow task after timeout is rescheduled and re-executed giving SideEffect another chance to succeed.

Executes the provided function once, records its result into the workflow history. The recorded result on history will be returned without executing the provided function during replay. This guarantees the deterministic requirement for workflow as the exact same result will be returned in replay. Common use case is to run some short non-deterministic code in workflow, like getting random number. The only way to fail SideEffect is to panic which causes workflow task failure. The workflow task after timeout is rescheduled and re-executed giving SideEffect another chance to succeed.

If function throws any exception it is not delivered to the workflow code. It is wrapped in Error causing failure of the current workflow task.

Type parameters

R

side effect result type

Value parameters

f

function that returns side effect value

Attributes

Returns

value of the side effect

See also
def sleep(duration: Duration): Unit

Suspends workflow execution until the given duration elapsed

Suspends workflow execution until the given duration elapsed

Value parameters

duration

time to sleep

Attributes

Returns

unblocks when duration elapsed

See also

Workflow.sleep

def upsertSearchAttributes(attrs: Map[String, ZSearchAttribute]): Unit

Adds or updates workflow search attributes.

Adds or updates workflow search attributes.

Value parameters

attrs

map of String to ZSearchAttribute value that can be used to search in list APIs

Attributes

See also

Workflow.upsertSearchAttributes

def version(changeId: String, minSupported: Int, maxSupported: Int): Int

Returns current workflow version

Returns current workflow version

Value parameters

changeId

identifier of a particular change. All calls to getVersion that share a changeId are guaranteed to return the same version number. Use this to perform multiple coordinated changes that should be enabled together.

maxSupported

max version supported for the change

minSupported

min version supported for the change

Attributes

Returns

version

See also

Workflow.getVersion

Inherited methods

inline def makeLogger: Logger

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

Get logger to use inside workflow. Logs in replay mode are omitted unless zio.temporal.worker.ZWorkerFactoryOptions.enableLoggingInReplay is set to 'true'.

The logger name will correspond to the enclosing class/trait name.

Attributes

Returns

logger to use in workflow logic.

Inherited from:
ZWorkflowVersionSpecific

Concrete fields

val DefaultVersion: Int