Files
tasks/chasm/parent_pointer_mock.go
Roey BermanandGitHub 1b972b2f28 Nexus workflow operation cancellation for CHASM (#9915)
## 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.
2026-04-13 10:48:26 -07:00

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,
},
}
}