Namespace: workflow
This library provides tools required for authoring workflows.
Usageβ
See the tutorial for writing your first workflow.
Timersβ
The recommended way of scheduling timers is by using the sleep function. We've replaced setTimeout
and
clearTimeout
with deterministic versions so these are also usable but have a limitation that they don't play well
with cancellation scopes.
import { sleep } from '@temporalio/workflow';
export async function sleeper(ms = 100): Promise<void> {
await sleep(ms);
console.log('slept');
}
Activitiesβ
To schedule Activities, use proxyActivities to obtain an Activity function and call.
Signals and Queriesβ
To add signal handlers to a Workflow, add a signals property to the exported workflow
object. Signal handlers can
return either void
or Promise<void>
, you may schedule activities and timers from a signal handler.
To add query handlers to a Workflow, add a queries property to the exported workflow
object. Query handlers must
not mutate any variables or generate any commands (like Activities or Timers), they run synchronously and thus
must return a Promise
.
Implementationβ
import { CancelledFailure, defineQuery, setHandler, condition } from '@temporalio/workflow';
import { unblockSignal } from './definitions';
export const isBlockedQuery = defineQuery<boolean>('isBlocked');
export async function unblockOrCancel(): Promise<void> {
let isBlocked = true;
setHandler(unblockSignal, () => void (isBlocked = false));
setHandler(isBlockedQuery, () => isBlocked);
try {
console.log('Blocked');
await condition(() => !isBlocked);
isBlocked = false;
console.log('Unblocked');
} catch (err) {
if (!(err instanceof CancelledFailure)) {
throw err;
}
console.log('Cancelled');
}
}
Moreβ
Enumerationsβ
Classesβ
- CancellationScope
- ContinueAsNew
- DeterminismViolationError
- IllegalStateError
- NamespaceNotFoundError
- PayloadConverterError
- Trigger
- ValueError
- WorkflowError
- WorkflowExecutionAlreadyStartedError
- WorkflowNotFoundError
Interfacesβ
- ActivateInput
- ActivityInput
- BaseWorkflowHandle
- BaseWorkflowOptions
- CancellationScopeOptions
- ChildWorkflowHandle
- ChildWorkflowOptions
- ConcludeActivationInput
- ContinueAsNewInput
- ContinueAsNewOptions
- DisposeInput
- EnhancedStackTrace
- ExternalWorkflowHandle
- FileLocation
- FileSlice
- LocalActivityInput
- ParentWorkflowInfo
- QueryInput
- SDKInfo
- SignalInput
- SignalWorkflowInput
- SinkCall
- StackTrace
- StartChildWorkflowExecutionInput
- TimerInput
- UnsafeWorkflowInfo
- WorkflowDurationOptions
- WorkflowExecuteInput
- WorkflowInboundCallsInterceptor
- WorkflowInfo
- WorkflowInterceptors
- WorkflowInternalsInterceptor
- WorkflowOutboundCallsInterceptor
Referencesβ
ActivityCancellationTypeβ
Re-exports ActivityCancellationType
ActivityFailureβ
Re-exports ActivityFailure
ActivityFunctionβ
Re-exports ActivityFunction
ActivityInterfaceβ
Re-exports ActivityInterface
ActivityOptionsβ
Re-exports ActivityOptions
ApplicationFailureβ
Re-exports ApplicationFailure
CancelledFailureβ
Re-exports CancelledFailure
ChildWorkflowFailureβ
Re-exports ChildWorkflowFailure
Headersβ
Re-exports Headers
LoggerSinksβ
Re-exports LoggerSinks
Nextβ
Re-exports Next
Payloadβ
Re-exports Payload
PayloadConverterβ
Re-exports PayloadConverter
QueryDefinitionβ
Re-exports QueryDefinition
RetryPolicyβ
Re-exports RetryPolicy
SearchAttributeValueβ
Re-exports SearchAttributeValue
SearchAttributesβ
Re-exports SearchAttributes
ServerFailureβ
Re-exports ServerFailure
SignalDefinitionβ
Re-exports SignalDefinition
TemporalFailureβ
Re-exports TemporalFailure
TerminatedFailureβ
Re-exports TerminatedFailure
TimeoutFailureβ
Re-exports TimeoutFailure
UntypedActivitiesβ
Re-exports UntypedActivities
Workflowβ
Re-exports Workflow
WorkflowQueryTypeβ
Re-exports WorkflowQueryType
WorkflowResultTypeβ
Re-exports WorkflowResultType
WorkflowReturnTypeβ
Re-exports WorkflowReturnType
WorkflowSignalTypeβ
Re-exports WorkflowSignalType
defaultPayloadConverterβ
Re-exports defaultPayloadConverter
rootCauseβ
Re-exports rootCause
Type Aliasesβ
ActivityInterfaceForβ
Ζ¬ ActivityInterfaceFor<T
>: { [K in keyof T]: T[K] extends ActivityFunction ? T[K] : typeof NotAnActivityMethod }
Type helper that takes a type T
and transforms attributes that are not ActivityFunction to
NotAnActivityMethod.
Example
Used by proxyActivities to get this compile-time error:
interface MyActivities {
valid(input: number): Promise<number>;
invalid(input: number): number;
}
const act = proxyActivities<MyActivities>({ startToCloseTimeout: '5m' });
await act.valid(true);
await act.invalid();
// ^ TS complains with:
// (property) invalidDefinition: typeof NotAnActivityMethod
// This expression is not callable.
// Type 'Symbol' has no call signatures.(2349)
Type parametersβ
Name |
---|
T |
CommonWorkflowOptionsβ
Ζ¬ CommonWorkflowOptions: BaseWorkflowOptions
& WorkflowDurationOptions
ConcludeActivationOutputβ
Ζ¬ ConcludeActivationOutput: ConcludeActivationInput
Output for WorkflowInternalsInterceptor.concludeActivation
ContinueAsNewInputOptionsβ
Ζ¬ ContinueAsNewInputOptions: ContinueAsNewOptions
& Required
<Pick
<ContinueAsNewOptions
, "workflowType"
>>
Same as ContinueAsNewOptions but workflowType must be defined
GetLogAttributesInputβ
Ζ¬ GetLogAttributesInput: Record
<string
, unknown
>
Input for WorkflowOutboundCallsInterceptor.getLogAttributes
Sinkβ
Ζ¬ Sink: Record
<string
, SinkFunction
>
A mapping of name to function, defines a single sink (e.g. logger)
SinkFunctionβ
Ζ¬ SinkFunction: (...args
: any
[]) => void
Type declarationβ
βΈ (...args
): void
Any function signature can be used for Sink functions as long as the return type is void
.
When calling a Sink function, arguments are copied from the Workflow isolate to the Node.js environment using postMessage.
This constrains the argument types to primitives (excluding Symbols).
Parametersβ
Name | Type |
---|---|
...args | any [] |
Returnsβ
void
Sinksβ
Ζ¬ Sinks: Record
<string
, Sink
>
Workflow Sink are a mapping of name to Sink
WithCompiledWorkflowOptionsβ
Ζ¬ WithCompiledWorkflowOptions<T
>: Replace
<T
, { workflowExecutionTimeout?
: IDuration
; workflowRunTimeout?
: IDuration
; workflowTaskTimeout?
: IDuration
}>
Type parametersβ
Name | Type |
---|---|
T | extends CommonWorkflowOptions |
WithWorkflowArgsβ
Ζ¬ WithWorkflowArgs<W
, T
>: T
& Parameters
<W
> extends [any
, ...any[]] ? { args
: Parameters
<W
> | Readonly
<Parameters
<W
>> } : { args?
: Parameters
<W
> | Readonly
<Parameters
<W
>> }
Type parametersβ
Name | Type |
---|---|
W | extends Workflow |
T | T |
WorkflowInterceptorsFactoryβ
Ζ¬ WorkflowInterceptorsFactory: () => WorkflowInterceptors
Type declarationβ
βΈ (): WorkflowInterceptors
A function that returns WorkflowInterceptors and takes no arguments.
Workflow interceptor modules should export an interceptors
function of this type.
Example
export function interceptors(): WorkflowInterceptors {
return {
inbound: [], // Populate with list of interceptor implementations
outbound: [], // Populate with list of interceptor implementations
internals: [], // Populate with list of interceptor implementations
};
}
Returnsβ
Variablesβ
AsyncLocalStorageβ
β’ Const
AsyncLocalStorage: <T>() => ALS
<T
>
Type declarationβ
β’ <T
>()
Type parametersβ
Name |
---|
T |
NotAnActivityMethodβ
β’ Const
NotAnActivityMethod: unique symbol
Symbol used in the return type of proxy methods to mark that an attribute on the source type is not a method.
See
enhancedStackTraceQueryβ
β’ Const
enhancedStackTraceQuery: QueryDefinition
<EnhancedStackTrace
, [], string
>
logβ
β’ Const
log: LoggerSinks
["defaultWorkerLogger"
]
Default workflow logger.
This logger is replay-aware and will omit log messages on workflow replay.
The messages emitted by this logger are funnelled to the worker's defaultSinks
, which are installed by default.
Note that since sinks are used to power this logger, any log attributes must be transferable via the postMessage API.
defaultSinks
accepts a user logger and defaults to the Runtime
's logger.
See the documentation for WorkerOptions
, defaultSinks
, and Runtime
for more information.
stackTraceQueryβ
β’ Const
stackTraceQuery: QueryDefinition
<string
, [], string
>
Functionsβ
addDefaultWorkflowOptionsβ
βΈ addDefaultWorkflowOptions<T
>(opts
): ChildWorkflowOptionsWithDefaults
Adds default values to workflowId
and workflowIdReusePolicy
to given workflow options.
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
opts | WithWorkflowArgs <T , ChildWorkflowOptions > |
Returnsβ
ChildWorkflowOptionsWithDefaults
compileWorkflowOptionsβ
βΈ compileWorkflowOptions<T
>(options
): WithCompiledWorkflowOptions
<T
>
Type parametersβ
Name | Type |
---|---|
T | extends CommonWorkflowOptions |
Parametersβ
Name | Type |
---|---|
options | T |
Returnsβ
WithCompiledWorkflowOptions
<T
>
conditionβ
βΈ condition(fn
, timeout
): Promise
<boolean
>
Returns a Promise that resolves when fn
evaluates to true
or timeout
expires.
Parametersβ
Name | Type | Description |
---|---|---|
fn | () => boolean | - |
timeout | Duration | number of milliseconds or ms-formatted string |
Returnsβ
Promise
<boolean
>
a boolean indicating whether the condition was true before the timeout expires
βΈ condition(fn
): Promise
<void
>
Returns a Promise that resolves when fn
evaluates to true
.
Parametersβ
Name | Type |
---|---|
fn | () => boolean |
Returnsβ
Promise
<void
>
continueAsNewβ
βΈ continueAsNew<F
>(...args
): Promise
<never
>
Continues-As-New the current Workflow Execution with default options.
Shorthand for makeContinueAsNewFunc<F>()(...args)
. (See: makeContinueAsNewFunc.)
Example
import { continueAsNew } from '@temporalio/workflow';
export async function myWorkflow(n: number): Promise<void> {
// ... Workflow logic
await continueAsNew<typeof myWorkflow>(n + 1);
}
Type parametersβ
Name | Type |
---|---|
F | extends Workflow |
Parametersβ
Name | Type |
---|---|
...args | Parameters <F > |
Returnsβ
Promise
<never
>
defineQueryβ
βΈ defineQuery<Ret
, Args
, Name
>(name
): QueryDefinition
<Ret
, Args
, Name
>
Define a query method for a Workflow.
Definitions are used to register handler in the Workflow via setHandler and to query Workflows using a WorkflowHandle. Definitions can be reused in multiple Workflows.
Type parametersβ
Name | Type |
---|---|
Ret | Ret |
Args | extends any [] = [] |
Name | extends string = string |
Parametersβ
Name | Type |
---|---|
name | Name |
Returnsβ
QueryDefinition
<Ret
, Args
, Name
>
defineSignalβ
βΈ defineSignal<Args
, Name
>(name
): SignalDefinition
<Args
, Name
>
Define a signal method for a Workflow.
Definitions are used to register handler in the Workflow via setHandler and to signal Workflows using a WorkflowHandle, ChildWorkflowHandle or ExternalWorkflowHandle. Definitions can be reused in multiple Workflows.
Type parametersβ
Name | Type |
---|---|
Args | extends any [] = [] |
Name | extends string = string |
Parametersβ
Name | Type |
---|---|
name | Name |
Returnsβ
SignalDefinition
<Args
, Name
>
deprecatePatchβ
βΈ deprecatePatch(patchId
): void
Indicate that a patch is being phased out.
See docs page for info.
Workflows with this call may be deployed alongside workflows with a patched call, but they must not be deployed while any workers still exist running old code without a patched call, or any runs with histories produced by such workers exist. If either kind of worker encounters a history produced by the other, their behavior is undefined.
Once all live workflow runs have been produced by workers with this call, you can deploy workers which are free of either kind of patch call for this ID. Workers with and without this call may coexist, as long as they are both running the "new" code.
Parametersβ
Name | Type | Description |
---|---|---|
patchId | string | An identifier that should be unique to this patch. It is OK to use multiple calls with the same ID, which means all such calls will always return the same value. |
Returnsβ
void
executeChildβ
βΈ executeChild<T
>(workflowType
, options
): Promise
<WorkflowResultType
<T
>>
Start a child Workflow execution and await its completion.
- By default, a child will be scheduled on the same task queue as its parent.
- This operation is cancellable using CancellationScopes.
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
workflowType | string |
options | WithWorkflowArgs <T , ChildWorkflowOptions > |
Returnsβ
Promise
<WorkflowResultType
<T
>>
The result of the child Workflow.
βΈ executeChild<T
>(workflowFunc
, options
): Promise
<WorkflowResultType
<T
>>
Start a child Workflow execution and await its completion.
- By default, a child will be scheduled on the same task queue as its parent.
- Deduces the Workflow type and signature from provided Workflow function.
- This operation is cancellable using CancellationScopes.
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
workflowFunc | T |
options | WithWorkflowArgs <T , ChildWorkflowOptions > |
Returnsβ
Promise
<WorkflowResultType
<T
>>
The result of the child Workflow.
βΈ executeChild<T
>(workflowType
): Promise
<WorkflowResultType
<T
>>
Start a child Workflow execution and await its completion.
Override for Workflows that accept no arguments.
- The child will be scheduled on the same task queue as its parent.
- This operation is cancellable using CancellationScopes.
Type parametersβ
Name | Type |
---|---|
T | extends () => WorkflowReturnType |
Parametersβ
Name | Type |
---|---|
workflowType | string |
Returnsβ
Promise
<WorkflowResultType
<T
>>
The result of the child Workflow.
βΈ executeChild<T
>(workflowFunc
): Promise
<WorkflowResultType
<T
>>
Start a child Workflow execution and await its completion.
Override for Workflows that accept no arguments.
- The child will be scheduled on the same task queue as its parent.
- Deduces the Workflow type and signature from provided Workflow function.
- This operation is cancellable using CancellationScopes.
Type parametersβ
Name | Type |
---|---|
T | extends () => WorkflowReturnType |
Parametersβ
Name | Type |
---|---|
workflowFunc | T |
Returnsβ
Promise
<WorkflowResultType
<T
>>
The result of the child Workflow.
extractWorkflowTypeβ
βΈ extractWorkflowType<T
>(workflowTypeOrFunc
): string
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
workflowTypeOrFunc | string | T |
Returnsβ
string
getExternalWorkflowHandleβ
βΈ getExternalWorkflowHandle(workflowId
, runId?
): ExternalWorkflowHandle
Returns a client-side handle that can be used to signal and cancel an existing Workflow execution. It takes a Workflow ID and optional run ID.
Parametersβ
Name | Type |
---|---|
workflowId | string |
runId? | string |
Returnsβ
inWorkflowContextβ
βΈ inWorkflowContext(): boolean
Returns whether or not code is executing in workflow context
Returnsβ
boolean
isCancellationβ
βΈ isCancellation(err
): boolean
Returns whether provided err
is caused by cancellation
Parametersβ
Name | Type |
---|---|
err | unknown |
Returnsβ
boolean
makeContinueAsNewFuncβ
βΈ makeContinueAsNewFunc<F
>(options?
): (...args
: Parameters
<F
>) => Promise
<never
>
Returns a function f
that will cause the current Workflow to ContinueAsNew when called.
f
takes the same arguments as the Workflow function supplied to typeparam F
.
Once f
is called, Workflow Execution immediately completes.
Type parametersβ
Name | Type |
---|---|
F | extends Workflow |
Parametersβ
Name | Type |
---|---|
options? | ContinueAsNewOptions |
Returnsβ
fn
βΈ (...args
): Promise
<never
>
Parametersβ
Name | Type |
---|---|
...args | Parameters <F > |
Returnsβ
Promise
<never
>
patchedβ
βΈ patched(patchId
): boolean
Patch or upgrade workflow code by checking or stating that this workflow has a certain patch.
See docs page for info.
If the workflow is replaying an existing history, then this function returns true if that
history was produced by a worker which also had a patched
call with the same patchId
.
If the history was produced by a worker without such a call, then it will return false.
If the workflow is not currently replaying, then this call always returns true.
Your workflow code should run the "new" code if this returns true, if it returns false, you should run the "old" code. By doing this, you can maintain determinism.
Parametersβ
Name | Type | Description |
---|---|---|
patchId | string | An identifier that should be unique to this patch. It is OK to use multiple calls with the same ID, which means all such calls will always return the same value. |
Returnsβ
boolean
proxyActivitiesβ
βΈ proxyActivities<A
>(options
): ActivityInterfaceFor
<A
>
Configure Activity functions with given ActivityOptions.
This method may be called multiple times to setup Activities with different options.
Example
import { proxyActivities } from '@temporalio/workflow';
import * as activities from '../activities';
// Setup Activities from module exports
const { httpGet, otherActivity } = proxyActivities<typeof activities>({
startToCloseTimeout: '30 minutes',
});
// Setup Activities from an explicit interface (e.g. when defined by another SDK)
interface JavaActivities {
httpGetFromJava(url: string): Promise<string>
someOtherJavaActivity(arg1: number, arg2: string): Promise<string>;
}
const {
httpGetFromJava,
someOtherJavaActivity
} = proxyActivities<JavaActivities>({
taskQueue: 'java-worker-taskQueue',
startToCloseTimeout: '5m',
});
export function execute(): Promise<void> {
const response = await httpGet("http://example.com");
// ...
}
Type parametersβ
Name | Type |
---|---|
A | UntypedActivities |
Parametersβ
Name | Type |
---|---|
options | ActivityOptions |
Returnsβ
a Proxy for which each attribute is a callable Activity function
proxyLocalActivitiesβ
βΈ proxyLocalActivities<A
>(options
): ActivityInterfaceFor
<A
>
Configure Local Activity functions with given LocalActivityOptions.
This method may be called multiple times to setup Activities with different options.
See
proxyActivities for examples
Type parametersβ
Name | Type |
---|---|
A | UntypedActivities |
Parametersβ
Name | Type |
---|---|
options | LocalActivityOptions |
Returnsβ
a Proxy for which each attribute is a callable Activity function
proxySinksβ
βΈ proxySinks<T
>(): T
Get a reference to Sinks for exporting data out of the Workflow.
These Sinks must be registered with the Worker in order for this mechanism to work.
Example
import { proxySinks, Sinks } from '@temporalio/workflow';
interface MySinks extends Sinks {
logger: {
info(message: string): void;
error(message: string): void;
};
}
const { logger } = proxySinks<MyDependencies>();
logger.info('setting up');
export function myWorkflow() {
return {
async execute() {
logger.info("hey ho");
logger.error("lets go");
}
};
}
Type parametersβ
Name | Type |
---|---|
T | extends Sinks |
Returnsβ
T
setDefaultSignalHandlerβ
βΈ setDefaultSignalHandler(handler
): void
Set a signal handler function that will handle signals calls for non-registered signal names.
Signals are dispatched to the default signal handler in the order that they were accepted by the server.
If this function is called multiple times for a given signal or query name the last handler will overwrite any previous calls.
Parametersβ
Name | Type | Description |
---|---|---|
handler | undefined | DefaultSignalHandler | a function that will handle signals for non-registered signal names, or undefined to unset the handler. |
Returnsβ
void
setHandlerβ
βΈ setHandler<Ret
, Args
, T
>(def
, handler
): void
Set a handler function for a Workflow query or signal.
If this function is called multiple times for a given signal or query name the last handler will overwrite any previous calls.
Type parametersβ
Name | Type |
---|---|
Ret | Ret |
Args | extends any [] |
T | extends SignalDefinition <Args , string > | QueryDefinition <Ret , Args , string > |
Parametersβ
Name | Type | Description |
---|---|---|
def | T | a SignalDefinition or QueryDefinition as returned by defineSignal or defineQuery respectively. |
handler | undefined | Handler <Ret , Args , T > | a compatible handler function for the given definition or undefined to unset the handler. |
Returnsβ
void
sleepβ
βΈ sleep(ms
): Promise
<void
>
Asynchronous sleep.
Schedules a timer on the Temporal service.
Parametersβ
Name | Type | Description |
---|---|---|
ms | Duration | sleep duration - number of milliseconds or ms-formatted string. If given a negative number or 0, value will be set to 1. |
Returnsβ
Promise
<void
>
startChildβ
βΈ startChild<T
>(workflowType
, options
): Promise
<ChildWorkflowHandle
<T
>>
Start a child Workflow execution
- Returns a client-side handle that implements a child Workflow interface.
- By default, a child will be scheduled on the same task queue as its parent.
A child Workflow handle supports awaiting completion, signaling and cancellation via CancellationScopes. In order to query the child, use a WorkflowClient from an Activity.
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
workflowType | string |
options | WithWorkflowArgs <T , ChildWorkflowOptions > |
Returnsβ
Promise
<ChildWorkflowHandle
<T
>>
βΈ startChild<T
>(workflowFunc
, options
): Promise
<ChildWorkflowHandle
<T
>>
Start a child Workflow execution
- Returns a client-side handle that implements a child Workflow interface.
- Deduces the Workflow type and signature from provided Workflow function.
- By default, a child will be scheduled on the same task queue as its parent.
A child Workflow handle supports awaiting completion, signaling and cancellation via CancellationScopes. In order to query the child, use a WorkflowClient from an Activity.
Type parametersβ
Name | Type |
---|---|
T | extends Workflow |
Parametersβ
Name | Type |
---|---|
workflowFunc | T |
options | WithWorkflowArgs <T , ChildWorkflowOptions > |
Returnsβ
Promise
<ChildWorkflowHandle
<T
>>
βΈ startChild<T
>(workflowType
): Promise
<ChildWorkflowHandle
<T
>>
Start a child Workflow execution
Override for Workflows that accept no arguments.
- Returns a client-side handle that implements a child Workflow interface.
- The child will be scheduled on the same task queue as its parent.
A child Workflow handle supports awaiting completion, signaling and cancellation via CancellationScopes. In order to query the child, use a WorkflowClient from an Activity.
Type parametersβ
Name | Type |
---|---|
T | extends () => Promise <any > |
Parametersβ
Name | Type |
---|---|
workflowType | string |
Returnsβ
Promise
<ChildWorkflowHandle
<T
>>
βΈ startChild<T
>(workflowFunc
): Promise
<ChildWorkflowHandle
<T
>>
Start a child Workflow execution
Override for Workflows that accept no arguments.
- Returns a client-side handle that implements a child Workflow interface.
- Deduces the Workflow type and signature from provided Workflow function.
- The child will be scheduled on the same task queue as its parent.
A child Workflow handle supports awaiting completion, signaling and cancellation via CancellationScopes. In order to query the child, use a WorkflowClient from an Activity.
Type parametersβ
Name | Type |
---|---|
T | extends () => Promise <any > |
Parametersβ
Name | Type |
---|---|
workflowFunc | T |
Returnsβ
Promise
<ChildWorkflowHandle
<T
>>
upsertSearchAttributesβ
βΈ upsertSearchAttributes(searchAttributes
): void
Updates this Workflow's Search Attributes by merging the provided searchAttributes
with the existing Search
Attributes, workflowInfo().searchAttributes
.
For example, this Workflow code:
upsertSearchAttributes({
CustomIntField: [1],
CustomBoolField: [true]
});
upsertSearchAttributes({
CustomIntField: [42],
CustomKeywordField: ['durable code', 'is great']
});
would result in the Workflow having these Search Attributes:
{
CustomIntField: [42],
CustomBoolField: [true],
CustomKeywordField: ['durable code', 'is great']
}
Parametersβ
Name | Type | Description |
---|---|---|
searchAttributes | SearchAttributes | The Record to merge. Use a value of [] to clear a Search Attribute. |
Returnsβ
void
uuid4β
βΈ uuid4(): string
Generate an RFC compliant V4 uuid. Uses the workflow's deterministic PRNG making it safe for use within a workflow. This function is cryptographically insecure. See the stackoverflow discussion.
Returnsβ
string
workflowInfoβ
βΈ workflowInfo(): WorkflowInfo
Get information about the current Workflow.
β οΈ We recommend calling workflowInfo()
whenever accessing WorkflowInfo fields. Some WorkflowInfo fields
change during the lifetime of an Executionβlike historyLength and
searchAttributesβand some may be changeable in the futureβlike taskQueue.
// GOOD
function myWorkflow() {
doSomething(workflowInfo().searchAttributes)
...
doSomethingElse(workflowInfo().searchAttributes)
}
// BAD
function myWorkflow() {
const attributes = workflowInfo().searchAttributes
doSomething(attributes)
...
doSomethingElse(attributes)
}
#### Returns
[`WorkflowInfo`](../interfaces/workflow.WorkflowInfo.md)