Workflow::sideEffect is useful for short, nondeterministic code snippets, such as getting a random
value or generating a UUID. It executes the provided function once and records its result into the
Workflow::sideEffect does not re-execute upon replay, but instead returns the
recorded result. It can be seen as an "inline" Activity.
Something to note about
is that, unlike the Temporal guarantee of at-most-once execution for Activities, there is no such
Workflow::sideEffect . Under certain failure conditions,
end up executing a function more than once.
The only way to fail
sideEffect is to throw an exception, which causes a decision task failure. After the
timeout, Temporal reschedules and then re-executes the decision task, giving
SideEffect another chance
to succeed. Do not return any data from
sideEffect other than through its recorded return value.
The following sample demonstrates how to use