mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
## What changed? This PR introduces two key features to enable out-of-the-box Nexus functionality with zero configuration: 1. **Always allow `temporal://system` callback URLs**: The `component.callbacks.allowedAddresses` configuration now automatically allows `temporal://system` URLs regardless of configured address rules. This special scheme+host combination bypasses normal URL validation and is always permitted. 2. **New UseSystemCallbackURL toggle**: Added `component.nexusoperations.useSystemCallbackURL` dynamic config that controls callback URL generation for worker targets: - When `false` (default): Uses the existing callback URL template approach - When `true`: Worker targets automatically get `temporal://system` - External targets continue to use template-generated URLs regardless of this setting - NOTE: if this toggle is `true` HTTPCallerProvider must be able to route internal requests based on theSource and Token headers. It should also override the path to `/nexus/callback`. See the HTTPCallerProvider code changes here. 3. **Callback URL Validation** has been refactored. The `AddressMatchRules` struct now includes a `Validate` method that handles the special `temporal://system` case and applies configured rules for other URLs. 4. **Callback Source Header**: will no longer be populated for external Targets. ## Why? Once `component.nexusoperations.useSystemCallbackURL` is enabled by default in a future release, these changes will allow Self-Hosted Temporal Servers to support Nexus with zero dynamic configuration See this issue: https://github.com/temporalio/temporal/issues/8298 ## How did you test it? - [x] built - [x] run locally and tested manually - [x] covered by existing tests - [x] added new unit test(s) - [x] added new functional test(s) --------- Co-authored-by: alex stanfield <[email protected]> Co-authored-by: Roey Berman <[email protected]>
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package nexus
|
|
|
|
import "go.temporal.io/server/common/routing"
|
|
|
|
type NamespaceAndTaskQueue struct {
|
|
Namespace string
|
|
TaskQueue string
|
|
}
|
|
|
|
var RouteDispatchNexusTaskByNamespaceAndTaskQueue = routing.NewBuilder[NamespaceAndTaskQueue]().
|
|
Constant("namespaces").
|
|
StringVariable("namespace", func(params *NamespaceAndTaskQueue) *string { return ¶ms.Namespace }).
|
|
Constant("task-queues").
|
|
StringVariable("task_queue", func(params *NamespaceAndTaskQueue) *string { return ¶ms.TaskQueue }).
|
|
Constant("nexus-services").
|
|
Build()
|
|
|
|
var RouteDispatchNexusTaskByEndpoint = routing.NewBuilder[string]().
|
|
Constant("nexus", "endpoints").
|
|
StringVariable("endpoint", func(endpoint *string) *string { return endpoint }).
|
|
Constant("services").
|
|
Build()
|
|
|
|
// RouteCompletionCallback is an HTTP route for completing a Nexus operation via callback.
|
|
var RouteCompletionCallback = routing.NewBuilder[string]().
|
|
Constant("namespaces").
|
|
StringVariable("namespace", func(namespace *string) *string { return namespace }).
|
|
Constant("nexus", "callback").
|
|
Build()
|
|
|
|
// PathCompletionCallbackNoIdentifier is an HTTP route for completing a Nexus operation via callback.
|
|
// Unlike RouteCompletionCallback it does not require any identifying information to be provided in the
|
|
// URL path. Instead the handler for this path is expected to look up identifying information through
|
|
// via the callback token in the headers.
|
|
var PathCompletionCallbackNoIdentifier = "/nexus/callback"
|