CHASM workflow command handler for Nexus#9109
CHASM workflow command handler for Nexus#9109stephanos merged 10 commits intotemporalio:nexus/hsm-to-chasm-migrationfrom
Conversation
0225b74 to
15b2305
Compare
| return []*chasm.RegistrableComponent{ | ||
| chasm.NewRegistrableComponent[*Operation]("operation"), | ||
| chasm.NewRegistrableComponent[*Operation]("cancellation"), | ||
| chasm.NewRegistrableComponent[*Cancellation]("cancellation"), |
5521052 to
125a6f1
Compare
3d0f476 to
cfe0179
Compare
| Callbacks chasm.Map[string, *callback.Callback] | ||
|
|
||
| // Operations map is used to store the nexus operations for the workflow. | ||
| Operations chasm.Map[string, *nexusoperation.Operation] |
There was a problem hiding this comment.
Not used yet, but demonstrates why command registry and types need to live in submodule. If they didn't there'd be an import cycle. Having this already ensures this design will work.
ceadf56 to
69632f8
Compare
|
|
||
| // FailWorkflowTaskError is an error that can be returned from a [CommandHandler] to fail the current workflow task and | ||
| // optionally terminate the entire workflow. | ||
| type FailWorkflowTaskError struct { |
There was a problem hiding this comment.
Moving this to CHASM now to break up import cycle.
| } | ||
|
|
||
| // CommandValidator is a helper for validating workflow commands. | ||
| type CommandValidator interface { |
There was a problem hiding this comment.
Moved to CHASM, too. More from this package might be moved in follow-up PRs.
| var commandHandler chasmcommand.Handler | ||
| var chasmCtx chasm.MutableContext | ||
|
|
||
| if handler.mutableState.ChasmEnabled() { |
There was a problem hiding this comment.
You will need a way to toggle between HSM and CHASM and you will have to figure out if and how to deal with a mutable state that has both HSM and CHASM nexus operations.
There was a problem hiding this comment.
To simplify the migration, we could set a point where we enable CHASM-backed operations. From that time on, new workflows will only use CHASM operations. Then we just have to wait 60 days to know that there are no more valid HSM operations since that is the maximum schedule-to-close timeout.
There was a problem hiding this comment.
I was under the impression the migration-related work is a separate ticket out of the scope of this PR. Let me know if you think we need to take action on this PR.
pdoerner
left a comment
There was a problem hiding this comment.
Overall LGTM. Just need to make a decision on whether the command handler registry should be specific to the workflow component or a general CHASM concept. I lean toward letting it be coupled with workflow but I don't have a strong opinion.
|
I made some changes after a team discussion, most importantly: moved the command handler registry out of the Workflow library; it is passed through the "engine" now just like HSM's. The benefit is that the additional It was also discussed to add it to |
da9c5b1 to
7f04034
Compare
| type Handler func( | ||
| chasmCtx chasm.MutableContext, | ||
| validator Validator, | ||
| workflowTaskCompletedEventID int64, |
There was a problem hiding this comment.
Maybe for forwards compat we can put this in an options struct?
| var commandHandler chasmcommand.Handler | ||
| var chasmCtx chasm.MutableContext | ||
|
|
||
| // TODO: need to handle migration between HSM and CHASM |
There was a problem hiding this comment.
Let's make sure this is tracked.
There was a problem hiding this comment.
👍 filed a ticket to make sure.
bergundy
left a comment
There was a problem hiding this comment.
Approved with a couple of very minor comments.
67fa6fe
into
temporalio:nexus/hsm-to-chasm-migration
## What changed? - Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. ## Why? Migrating Nexus from HSM to CHASM. ## How did you test it? Tests will be ported over once actual command handler implementations are added.
## What changed? - Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. ## Why? Migrating Nexus from HSM to CHASM. ## How did you test it? Tests will be ported over once actual command handler implementations are added.
## What changed? - Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. ## Why? Migrating Nexus from HSM to CHASM. ## How did you test it? Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
- Added workflow command handler registry to CHASM's workflow library. - Integrated CHASM's workflow library into workflow completion handler. Migrating Nexus from HSM to CHASM. Tests will be ported over once actual command handler implementations are added.
What changed?
Why?
Migrating Nexus from HSM to CHASM.
How did you test it?
Tests will be ported over once actual command handler implementations are added.