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.
Implements
Constructors
constructor
• new WorkflowActivation(properties?
): WorkflowActivation
Constructs a new WorkflowActivation.
Parameters
Name | Type | Description |
---|---|---|
properties? | IWorkflowActivation | Properties to set |
Returns
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
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
timestamp
• Optional
timestamp: null
| ITimestamp
The current time as understood by the workflow, which is set by workflow task started events
Implementation of
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
Name | Type | Description |
---|---|---|
properties? | IWorkflowActivation | Properties to set |
Returns
WorkflowActivation instance
decode
▸ decode(reader
, length?
): WorkflowActivation
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
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 | IWorkflowActivation | 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 | IWorkflowActivation | 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
getTypeUrl
▸ getTypeUrl(typeUrlPrefix?
): string
Gets the default type url for WorkflowActivation
Parameters
Name | Type | Description |
---|---|---|
typeUrlPrefix? | string | your 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
Name | Type | Description |
---|---|---|
message | WorkflowActivation | WorkflowActivation |
options? | IConversionOptions | Conversion options |
Returns
Object
Plain object