Skip to content

Add chasm.Context.ExecutionKey() method#8533

Merged
bergundy merged 3 commits into
temporalio:mainfrom
bergundy:chasm-context-execution-key
Oct 24, 2025
Merged

Add chasm.Context.ExecutionKey() method#8533
bergundy merged 3 commits into
temporalio:mainfrom
bergundy:chasm-context-execution-key

Conversation

@bergundy
Copy link
Copy Markdown
Member

What changed?

  • Add chasm.Context.ExecutionKey() method
  • Refactor context.go to use better struct names and unexport concepts that should not be exported
  • Add some docstrings

Copy link
Copy Markdown
Member

@yycptt yycptt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the renaming and new docstring!

Comment thread chasm/context.go
Comment thread chasm/context.go
@bergundy bergundy force-pushed the chasm-context-execution-key branch from 11c55a7 to 1deea1a Compare October 24, 2025 16:09
@bergundy bergundy force-pushed the chasm-context-execution-key branch from 1deea1a to cd4c58a Compare October 24, 2025 17:17
Comment thread chasm/node_backend_mock.go Outdated
)

// MockNodeBackend is a lightweight manual mock for the NodeBackend interface.
// Methods may be stubbed by assigning the corresponding Handle fields. Call history
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Methods may be stubbed by assigning the corresponding Handle fields. Call history
// Methods may be stubbed by assigning the corresponding Handle fields. Update call history

// Methods may be stubbed by assigning the corresponding Handle fields. Call history
// is recorded in the struct fields (thread-safe).
type MockNodePureTask struct {
HandleExecutePureTask func(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Execute only returns an error

Comment thread chasm/lib/scheduler/helper_test.go Outdated
}
nodeBackend.EXPECT().CurrentVersionedTransition().Return(currentVT).AnyTimes()
nodeBackend.EXPECT().AddTasks(gomock.Any()).Return().AnyTimes()
nodeBackend.HandleIsWorkflow = func() bool { return false }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not needed and duplicates L91

TransitionCount: 1,
nodeBackend.HandleNextTransitionCount = func() int64 { return 2 }
nodeBackend.HandleGetCurrentVersion = func() int64 { return 1 }
nodeBackend.HandleGetWorkflowKey = tv.Any().WorkflowKey
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe tv.Any().WorkflowKey can be the default?

HandleCurrentVersionedTransition: func() *persistencespb.VersionedTransition {
return &persistencespb.VersionedTransition{
NamespaceFailoverVersion: 1,
TransitionCount: 2,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TransitionCount: 2,
TransitionCount: 1,

Comment thread chasm/tree_test.go
Comment on lines -1903 to -1906
s.nodeBackend.EXPECT().UpdateWorkflowStateStatus(
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
enumspb.WORKFLOW_EXECUTION_STATUS_TERMINATED,
).Return(true, nil).Times(1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do want to validate those Update calls and the state & status parameter.

Comment thread chasm/tree_test.go
Comment on lines -2512 to -2515
s.nodeBackend.EXPECT().UpdateWorkflowStateStatus(
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
enumspb.WORKFLOW_EXECUTION_STATUS_TERMINATED,
).Return(true, nil).Times(1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz assert this.

Comment thread chasm/tree_test.go Outdated

func (s *nodeSuite) TestExecuteImmediatePureTask() {
tv := testvars.New(s.T())
// tv := testvars.New(s.T())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

@bergundy bergundy merged commit 7be52d5 into temporalio:main Oct 24, 2025
94 of 96 checks passed
@bergundy bergundy deleted the chasm-context-execution-key branch October 24, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants