Skip to main content

Class: WorkflowActivation

coresdk.workflow_activation.WorkflowActivation

An instruction to the lang sdk to run some workflow code, whether for the first time or from a cached state.

Job ordering guarantees and semantics

Core will, by default, order jobs within the activation as follows: patches -> signals/updates -> other -> queries -> evictions

This is because:

  • Patches are expected to apply to the entire activation
  • Signal and update handlers should be invoked before workflow routines are iterated. That is to say before the users' main workflow function and anything spawned by it is allowed to continue.
  • Queries always go last (and, in fact, always come in their own activation)
  • Evictions also always come in their own activation

The downside of this reordering is that a signal or update handler may not observe that some other event had already happened (ex: an activity completed) when it is first invoked, though it will subsequently when workflow routines are driven. Core only does this reordering to make life easier for languages that cannot explicitly control when workflow routines are iterated. Languages that can explicitly control such iteration should prefer to apply all the jobs to state (by resolving promises/futures, invoking handlers, etc as they iterate over the jobs) and then only after that is done, drive the workflow routines.

Evictions

Evictions appear as an activations that contains only a remove_from_cache job. Such activations should not cause the workflow code to be invoked and may be responded to with an empty command list.

Implements

Constructors

constructor

new WorkflowActivation(properties?): WorkflowActivation

Constructs a new WorkflowActivation.

Parameters

NameTypeDescription
properties?IWorkflowActivationProperties to set

Returns

WorkflowActivation

Properties

availableInternalFlags

availableInternalFlags: number[]

Internal flags which are available for use by lang. If is_replaying is false, all internal flags may be used. This is not a delta - all previously used flags always appear since this representation is cheap.

Implementation of

IWorkflowActivation.availableInternalFlags


buildIdForCurrentTask

buildIdForCurrentTask: string

Set to the Build ID of the worker that processed this task, which may be empty. During replay this id may not equal the id of the replaying worker. If not replaying and this worker has a defined Build ID, it will equal that ID. It will also be empty for evict-only activations.

Implementation of

IWorkflowActivation.buildIdForCurrentTask


continueAsNewSuggested

continueAsNewSuggested: boolean

Set true if the most recent WFT started event had this suggestion

Implementation of

IWorkflowActivation.continueAsNewSuggested


historyLength

historyLength: number

Current history length as determined by the event id of the most recently processed event. This ensures that the number is always deterministic

Implementation of

IWorkflowActivation.historyLength


historySizeBytes

historySizeBytes: Long

The history size in bytes as of the last WFT started event

Implementation of

IWorkflowActivation.historySizeBytes


isReplaying

isReplaying: boolean

Whether or not the activation is replaying past events

Implementation of

IWorkflowActivation.isReplaying


jobs

jobs: IWorkflowActivationJob[]

The things to do upon activating the workflow

Implementation of

IWorkflowActivation.jobs


runId

runId: string

The id of the currently active run of the workflow. Also used as a cache key. There may only ever be one active workflow task (and hence activation) of a run at one time.

Implementation of

IWorkflowActivation.runId


timestamp

Optional timestamp: null | ITimestamp

The current time as understood by the workflow, which is set by workflow task started events

Implementation of

IWorkflowActivation.timestamp

Methods

toJSON

toJSON(): Object

Converts this WorkflowActivation to JSON.

Returns

Object

JSON object


create

create(properties?): WorkflowActivation

Creates a new WorkflowActivation instance using the specified properties.

Parameters

NameTypeDescription
properties?IWorkflowActivationProperties to set

Returns

WorkflowActivation

WorkflowActivation instance


decode

decode(reader, length?): WorkflowActivation

Decodes a WorkflowActivation message from the specified reader or buffer.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from
length?numberMessage length if known beforehand

Returns

WorkflowActivation

WorkflowActivation

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited

decodeDelimited(reader): WorkflowActivation

Decodes a WorkflowActivation message from the specified reader or buffer, length delimited.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns

WorkflowActivation

WorkflowActivation

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


encode

encode(message, writer?): Writer

Encodes the specified WorkflowActivation message. Does not implicitly coresdk.workflow_activation.WorkflowActivation.verify|verify messages.

Parameters

NameTypeDescription
messageIWorkflowActivationWorkflowActivation message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


encodeDelimited

encodeDelimited(message, writer?): Writer

Encodes the specified WorkflowActivation message, length delimited. Does not implicitly coresdk.workflow_activation.WorkflowActivation.verify|verify messages.

Parameters

NameTypeDescription
messageIWorkflowActivationWorkflowActivation message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


fromObject

fromObject(object): WorkflowActivation

Creates a WorkflowActivation message from a plain object. Also converts values to their respective internal types.

Parameters

NameTypeDescription
objectObjectPlain object

Returns

WorkflowActivation

WorkflowActivation


getTypeUrl

getTypeUrl(typeUrlPrefix?): string

Gets the default type url for WorkflowActivation

Parameters

NameTypeDescription
typeUrlPrefix?stringyour custom typeUrlPrefix(default "type.googleapis.com")

Returns

string

The default type url


toObject

toObject(message, options?): Object

Creates a plain object from a WorkflowActivation message. Also converts values to other types if specified.

Parameters

NameTypeDescription
messageWorkflowActivationWorkflowActivation
options?IConversionOptionsConversion options

Returns

Object

Plain object