You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Potentially we could just set the version at starting workflow API call. and then the workflow code will use the version from input.
(in fact, this is what SWF (the ancestor of Cadence/Temporal) reccomends )
As Cadence/Temporal also allows us to upsert SA at start API, we could just use that as input + SA.
However, the downside of simply doing it is that we lose the ability to reset the workflow to beginning (firstWorkflowTask) to pick up the latest version, since the version is already fixed as input.
To minimize this side effect, we can do something like this at the beginning of the workflow code:
versionFromInput = workflow.getInfo().getSearchAttribute(TEMPORAL_GLBOAL_VERSION);
intactualVersion;
if !workflow.isReplay() {
ifMAX_VERSION_OF_ALL > versionFromInput {
// this means that we can pick up the newer version(it's probably after a reset, or the start API code is outdated on max version)actualVersion = workflow.getVersion("global", Workflow.DEFAULT_VERSION, MAX_VERSION_OF_ALL);
// also need to overwrite the saworkflow.upsertSearchAttribute(TEMPORAL_GLBOAL_VERSION, actualVersion);
}elseifMAX_VERSION_OF_ALL < versionFromInput {
thrownewRuntimeException("this means the startWF API knows a version larger than this worker can support, we just fail the workflow task to retry");
} else{
// the ideal situation to save the two Temporal actions(version marker+upsertSA)actualVersion = versionFromInput;
}
}else{
// in replay mode, it will not cost anything// if there is no version marker in the history, it will return the MAX_INTEGER.// if there is a marker in the history, it will use the value from markeractualVersion = workflow.getVersion("global", Workflow.DEFAULT_VERSION, MAX_INTEGER);
ifactualVersion == MAX_INTEGER{
// this means that there is no version marker in the historyactualVersion = versionFromInput
}else{
// also call the upsertSearchAttribute so that we don't break the determinism...workflow.upsertSearchAttribute(TEMPORAL_GLBOAL_VERSION, actualVersion);
}
}
The text was updated successfully, but these errors were encountered:
Potentially we could just set the version at starting workflow API call. and then the workflow code will use the version from input.
(in fact, this is what SWF (the ancestor of Cadence/Temporal) reccomends )
As Cadence/Temporal also allows us to upsert SA at start API, we could just use that as input + SA.
However, the downside of simply doing it is that we lose the ability to reset the workflow to beginning (firstWorkflowTask) to pick up the latest version, since the version is already fixed as input.
To minimize this side effect, we can do something like this at the beginning of the workflow code:
The text was updated successfully, but these errors were encountered: