Files
tasks/chasm/nexus_completion.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

48 lines
1.7 KiB
Go

package chasm
import (
"encoding/base64"
commonpb "go.temporal.io/api/common/v1"
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
)
// NexusCompletionHandlerURL is the user-visible URL for Nexus->CHASM callbacks.
const NexusCompletionHandlerURL = "temporal://internal"
// NexusCompletionHandler is implemented by CHASM components that want to handle Nexus operation completion callbacks.
type NexusCompletionHandler interface {
HandleNexusCompletion(ctx MutableContext, completion *persistencespb.ChasmNexusCompletion) error
}
// NexusCompletionHandlerComponent is a CHASM [Component] that also implements [NexusCompletionHandler].
type NexusCompletionHandlerComponent interface {
Component
NexusCompletionHandler
}
// GenerateNexusCallback generates a Callback message indicating a CHASM component to receive Nexus operation completion
// callbacks. Particularly useful for components that want to track a workflow start with StartWorkflowExecution.
func GenerateNexusCallback(ctx Context, component NexusCompletionHandlerComponent) (*commonpb.Callback, error) {
ref, err := ctx.Ref(component)
if err != nil {
return nil, err
}
encodedRef := base64.RawURLEncoding.EncodeToString(ref)
headers := map[string]string{
// NOTE: There's a constant defined for this in common/nexus but to avoid circular dependencies we redefine it here.
// This is acceptable since we are going to eventually have a strongly typed field for passing tokens around.
"temporal-callback-token": encodedRef,
}
return &commonpb.Callback{
Variant: &commonpb.Callback_Nexus_{
Nexus: &commonpb.Callback_Nexus{
Url: NexusCompletionHandlerURL,
Header: headers,
},
},
}, nil
}