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:
- init workflow
- patches
- random-seed-updates
- signals/updates
- all others
- local activity resolutions
- 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.
- Local activities resolutions go after other normal jobs because while not replaying, they will always take longer than anything else that produces an immediate job (which is effectively instant). When replaying we need to scan ahead for LA markers so that we can resolve them in the same activation that they completed in when not replaying. However, doing so would, by default, put those resolutions before any other immediate jobs that happened in that same activation (prime example: cancelling not-wait-for-cancel activities). So, we do this to ensure the LA resolution happens after that cancel (or whatever else it may be) as it normally would have when executing.
- Queries always go last (and, in fact, always come in their own activation)
- Evictions also always come in their own activation
Core does this reordering to ensure that langs observe jobs in the same order during replay as they would have during execution. However, in principle, this ordering is not necessary (excepting queries/evictions, which definitely must come last) if lang layers apply all jobs to state first (by resolving promises/futures, marking handlers to be invoked, etc as they iterate over the jobs) and then only after that is done, drive coroutines/threads/whatever. If execution works this way, then determinism is only impacted by the order routines are driven in (which must be stable based on lang implementation or convention), rather than the order jobs are processed.
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.
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.
continueAsNewSuggested
• continueAsNewSuggested: boolean
Set true if the most recent WFT started event had this suggestion
deploymentVersionForCurrentTask
• Optional deploymentVersionForCurrentTask: null | $Properties
Set to the deployment version of the worker that processed this task, which may be empty. During replay this version may not equal the version of the replaying worker. If not replaying and this worker has a defined Deployment Version, it will equal that. It will also be empty for evict-only activations. The deployment name may be empty, but not the build id, if this worker was using the deprecated Build ID-only feature(s).
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
historySizeBytes
• historySizeBytes: Long
The history size in bytes as of the last WFT started event
isReplaying
• isReplaying: boolean
Whether or not the activation is replaying past events
jobs
• jobs: $Properties[]
The things to do upon activating the workflow
lastSdkVersion
• lastSdkVersion: string
The last seen SDK version from the most recent WFT completed event
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.
suggestContinueAsNewReasons
• suggestContinueAsNewReasons: SuggestContinueAsNewReason[]
Experimental. Optionally decide the versioning behavior that the first task of the new run should use. For example, choose to AutoUpgrade on continue-as-new instead of inheriting the pinned version of the previous run.
targetWorkerDeploymentVersionChanged
• targetWorkerDeploymentVersionChanged: boolean
True if Workflow's Target Worker Deployment Version is different from its Pinned Version and the workflow is Pinned. Experimental.
timestamp
• Optional timestamp: null | $Properties
The current time as understood by the workflow, which is set by workflow task started events
Methods
toJSON
▸ toJSON(): Object
Converts this WorkflowActivation to JSON.
Returns
Object
JSON object
create
▸ create(properties?): WorkflowActivation & $Shape
Creates a new WorkflowActivation instance using the specified properties.
Parameters
| Name | Type | Description |
|---|---|---|
properties? | $Shape | Properties to set |
Returns
WorkflowActivation instance
▸ create(properties?): WorkflowActivation
Parameters
| Name | Type |
|---|---|
properties? | $Properties |
Returns
decode
▸ decode(reader, length?): WorkflowActivation & $Shape
Decodes a WorkflowActivation message from the specified reader or buffer.
Parameters
| Name | Type | Description |
|---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
length? | number | Message length if known beforehand |
Returns
WorkflowActivation
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
decodeDelimited
▸ decodeDelimited(reader): WorkflowActivation & $Shape
Decodes a WorkflowActivation message from the specified reader or buffer, length delimited.
Parameters
| Name | Type | Description |
|---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
Returns
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
| Name | Type | Description |
|---|---|---|
message | $Properties | WorkflowActivation message or plain object to encode |
writer? | Writer | Writer 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
| Name | Type | Description |
|---|---|---|
message | $Properties | WorkflowActivation message or plain object to encode |
writer? | Writer | Writer 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
| Name | Type | Description |
|---|---|---|
object | Object | Plain object |
Returns
WorkflowActivation
toObject
▸ toObject(message, options?): Object
Creates a plain object from a WorkflowActivation message. Also converts values to other types if specified.
Parameters
| Name | Type | Description |
|---|---|---|
message | WorkflowActivation | WorkflowActivation |
options? | IConversionOptions | Conversion options |
Returns
Object
Plain object