Skip to content

Conversation

spkane31
Copy link
Contributor

What changed?

Adding an InvocationTaskExecutor and BackoffTaskExecutor to chasm/lib/callback

Why?

Second step of migrating callback from HSM -> CHASM

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

None, this is not integrated.

@spkane31 spkane31 requested a review from bergundy October 20, 2025 15:39
@spkane31 spkane31 marked this pull request as ready for review October 20, 2025 16:17
@spkane31 spkane31 requested review from a team as code owners October 20, 2025 16:17
@spkane31 spkane31 requested a review from pdoerner October 20, 2025 19:26
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Please use chasm/statemachine.go and copy over all of the state transitions from the HSM implementation.

_, err := chasm.ReadComponent(
ctx,
invokerRef,
func(c *Callback, ctx chasm.Context, _ any) (struct{}, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Just return what you need here instead of cloning the entire proto IMHO. I typically would rather not cloning components for use outside of the chasm contexts.

task *callbackspb.InvocationTask,
) error {
var ns *namespace.Namespace
// var invoker *Invoker
Copy link
Member

Choose a reason for hiding this comment

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

Leftover comment.

) error {
var ns *namespace.Namespace
// var invoker *Invoker
var callback *Callback
Copy link
Member

Choose a reason for hiding this comment

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

This can be the return type from ReadComponent.

_ chasm.TaskAttributes,
_ *callbackspb.InvocationTask,
) (bool, error) {
return callback.Status == callbackspb.CALLBACK_STATUS_SCHEDULED, nil
Copy link
Member

Choose a reason for hiding this comment

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

We should also validate the attempt matches, copy the attempt to the invocation task when scheduled. This would prevent duplicate tasks from being considered valid in some cases.

case *callbackspb.Callback_Nexus:
// Parse URL to extract scheme and host, matching HSM's behavior
// from statemachine.go:86-90
u, err := url.Parse(variant.Nexus.Url)
Copy link
Member

Choose a reason for hiding this comment

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

@chaptersix we should follow up and change this to use the destination in the token in case the URL is temporal://system.

map<string, string> header = 2;
}

message InvokerState {
Copy link
Member

Choose a reason for hiding this comment

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

What is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed


// Fields from HSM's nexusInvocation struct (nexus_invocation.go:35-40)
// These hold the invocation context needed for the HTTP request
completion nexusrpc.OperationCompletion
Copy link
Member

Choose a reason for hiding this comment

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

Don't hold this here, create a separate struct for that as we did in the HSM version.

// - HSM invocationResultOK -> CHASM CALLBACK_STATUS_SUCCEEDED
// - HSM invocationResultRetry -> CHASM CALLBACK_STATUS_BACKING_OFF
// - HSM invocationResultFail -> CHASM CALLBACK_STATUS_FAILED
func (c *Callback) invoke(
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be a method on the component. I know we did this pattern in scheduler but I do not want us to reference components in general outside of the chasm context, it's too error prone and hard to reason about.

)
defer cancel()

result := callback.invoke(callCtx, ns, e, taskAttributes, task)
Copy link
Member

Choose a reason for hiding this comment

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

You're missing the chasm variant that @lina-temporal recently added.

Comment on lines +36 to +40

string workflow_id = 10;
string run_id = 11;

string namespace_id = 12;
Copy link
Member

Choose a reason for hiding this comment

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

What is this for?

Copy link
Contributor Author

@spkane31 spkane31 Oct 21, 2025

Choose a reason for hiding this comment

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

Namespace is used to get request timeout from dynamic config on a per-namespace basis

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