mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package frontend
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/blang/semver/v4"
|
|
"go.temporal.io/api/workflowservice/v1"
|
|
"github.com/hanzoai/tasks/common/headers"
|
|
)
|
|
|
|
// Overrides defines a set of special case behaviors like compensating for buggy
|
|
// SDK implementations
|
|
type Overrides struct {
|
|
minTypeScriptEagerActivitySupportedVersion semver.Version
|
|
}
|
|
|
|
func NewOverrides() *Overrides {
|
|
return &Overrides{
|
|
minTypeScriptEagerActivitySupportedVersion: semver.MustParse("1.4.4"),
|
|
}
|
|
}
|
|
|
|
func (o *Overrides) shouldForceDisableEagerDispatch(sdkName, sdkVersion string) bool {
|
|
if sdkName == headers.ClientNamePythonSDK && (sdkVersion == "0.1a1" || sdkVersion == "0.1a2" || sdkVersion == "0.1b1" || sdkVersion == "0.1b2") {
|
|
return true
|
|
} else if sdkName == headers.ClientNameTypeScriptSDK {
|
|
ver, err := semver.Parse(sdkVersion)
|
|
// Don't bother with non semver
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return ver.LT(o.minTypeScriptEagerActivitySupportedVersion)
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (o *Overrides) disableEagerDispatch(
|
|
request *workflowservice.RespondWorkflowTaskCompletedRequest,
|
|
) {
|
|
for _, cmd := range request.GetCommands() {
|
|
attrs := cmd.GetScheduleActivityTaskCommandAttributes()
|
|
if attrs != nil {
|
|
attrs.RequestEagerExecution = false
|
|
}
|
|
}
|
|
}
|
|
|
|
// DisableEagerActivityDispatchForBuggyClients compensates for SDK versions
|
|
// that have buggy implementations of eager activity dispatch
|
|
func (o *Overrides) DisableEagerActivityDispatchForBuggyClients(
|
|
ctx context.Context,
|
|
request *workflowservice.RespondWorkflowTaskCompletedRequest,
|
|
) {
|
|
sdkName, sdkVersion := headers.GetClientNameAndVersion(ctx)
|
|
if o.shouldForceDisableEagerDispatch(sdkName, sdkVersion) {
|
|
o.disableEagerDispatch(request)
|
|
}
|
|
}
|