Skip to main content

worker.ApplyMode

Controls how an external dependency function is executed.

  • ASYNC* variants run at the end of an activation and do not block the isolate.
  • SYNC* variants run during Workflow activation and block the isolate, they're passed into the isolate using an isolated-vm Reference

The Worker will log if an error occurs in one of ignored variants.

NOTE: External dependencies are an advanced feature and should be used with caution

  • Do not return anything that can break Workflow execution determinism
  • Synchronous variants should be used as a last resort and their execution time should be kept short to free up the Workflow thread

Enumeration members#

ASYNC#

ASYNC: = "async"

Injected function will be called at the end of an activation. Isolate enqueues function to be called during activation and registers a callback to await its completion. Use if exposing an async function to the isolate for which the result should be returned to the isolate.


ASYNC_IGNORED#

ASYNC_IGNORED: = "asyncIgnored"

Injected function will be called at the end of an activation. Isolate enqueues function to be called during activation and does not register a callback to await its completion. This is the safest async ApplyMode because it can not break Workflow code determinism. Can only be used when the injected function returns void and the implementation returns void or Promise<void>.


SYNC#

SYNC: = "applySync"

Injected function is called synchronously, implementation must be a synchronous function. Injection is done using an isolated-vm reference, function is called with applySync.


SYNC_IGNORED#

SYNC_IGNORED: = "applyIgnored"

Injected function is called in the background not blocking the isolate. Implementation can be either synchronous or asynchronous. Injection is done using an isolated-vm reference, function is called with applyIgnored.

This is the safest sync ApplyMode because it can not break Workflow code determinism.


SYNC_PROMISE#

SYNC_PROMISE: = "applySyncPromise"

Injected function is called synchronously, implementation must return a promise. Injection is done using an isolated-vm reference, function is called with applySyncPromise.