mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Full implementation of the cancellation path for workflow Nexus operations on CHASM. Including: - State machine logic - Component logic - Workflow event handlers - Integration into workflows - Executors I also ended up doing quite a bit of refactoring to reuse as much of the code as possible across the cancellation and invocation executors. Also added missing test coverage for the invocation executors. I tried to structure this into separate commits that make reviews easy but ended up with a lot of fixes in later commits that touched code in earlier commits. Best to review in one piece.
35 lines
963 B
Go
35 lines
963 B
Go
package chasm
|
|
|
|
import (
|
|
persistencespb "go.temporal.io/server/api/persistence/v1"
|
|
"go.temporal.io/server/common/log"
|
|
)
|
|
|
|
// NewMockParentPtr creates a ParentPtr[T] backed by real Node instances
|
|
// that returns the given parent value when Get or TryGet is called.
|
|
// This is intended for use in unit tests where a full CHASM tree is not needed.
|
|
func NewMockParentPtr[T any](parent T) ParentPtr[T] {
|
|
base := &nodeBase{
|
|
logger: log.NewNoopLogger(),
|
|
}
|
|
|
|
parentNode := newNode(base, nil, "")
|
|
parentNode.serializedNode = &persistencespb.ChasmNode{
|
|
Metadata: &persistencespb.ChasmNodeMetadata{
|
|
Attributes: &persistencespb.ChasmNodeMetadata_ComponentAttributes{
|
|
ComponentAttributes: &persistencespb.ChasmComponentAttributes{},
|
|
},
|
|
},
|
|
}
|
|
parentNode.value = parent
|
|
parentNode.valueState = valueStateSynced
|
|
|
|
childNode := newNode(base, parentNode, "mock_child")
|
|
|
|
return ParentPtr[T]{
|
|
Internal: parentPtrInternal{
|
|
currentNode: childNode,
|
|
},
|
|
}
|
|
}
|