mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
Goes from 135 MB binary with 1153 files importing go.temporal.io and 224
importing google.golang.org/grpc to a 10 MB native binary with ZERO of
either.
Deleted:
- tasks/, tasktests/, service/, chasm/, client/, api/, proto/, tools/
- cmd/tools/, components/, docker/
- schema/{cassandra,elasticsearch,mysql,postgresql,sqlite}/
- 40 tainted common/ subdirs + 7 top-level common files
- tests/testutils (no longer referenced after surviving deps drop common)
New cmd/tasksd (~100 lines) boots tasks.Embed (zap.Node) + http.Server.
New pkg/tasks/embed.go registers ZAP handlers for the SDK opcode surface
(0x0060-0x00A5). Workflow handlers return a 501 "not yet implemented"
envelope; native engine lands behind this contract.
Build: go build ./cmd/tasksd → 10 MB
Vet: go vet ./... → clean
Boot: tasksd --zap-port 9999 --http :7243
Probes: /healthz, /v1/tasks/health → 200
UI: /_/tasks/, / → 200 (embedded Vite bundle)
ZAP: _tasks._tcp on :9999 (mDNS disabled; direct connect)
go.mod: tidy. No go.temporal.io. No google.golang.org/grpc.
67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
workflowpb "go.temporal.io/api/workflow/v1"
|
|
"go.temporal.io/server/common/namespace"
|
|
"go.temporal.io/server/common/worker_versioning"
|
|
)
|
|
|
|
// VersionReactivationSignalerFn is a function type for sending reactivation signals to version workflows.
|
|
// This abstraction allows the history API layer to use the deployment client without importing it directly,
|
|
// avoiding import cycles between history/api and worker/workerdeployment packages.
|
|
// revisionNumber is the version's current revision per matching's view and is used by the signaler
|
|
// to compose a cluster-wide-deterministic RequestId on the signal for receiver-side dedup.
|
|
type VersionReactivationSignalerFn func(
|
|
ctx context.Context,
|
|
namespaceEntry *namespace.Namespace,
|
|
deploymentName, buildID string,
|
|
revisionNumber int64,
|
|
) error
|
|
|
|
// ReactivateVersionWorkflowIfPinned sends a reactivation signal to the version workflow
|
|
// when workflows are pinned to a potentially DRAINED/INACTIVE version.
|
|
// This is a fire-and-forget operation - the signal is sent asynchronously and errors are
|
|
// logged by the signaler implementation. The signaler itself is responsible for per-pod
|
|
// dedup by revision number; cross-pod duplicates fold at the receiver via a deterministic
|
|
// UUID RequestId.
|
|
//
|
|
//nolint:revive,errcheck
|
|
func ReactivateVersionWorkflowIfPinned(
|
|
ctx context.Context,
|
|
namespaceEntry *namespace.Namespace,
|
|
override *workflowpb.VersioningOverride,
|
|
signaler VersionReactivationSignalerFn,
|
|
enabled bool,
|
|
shouldSkipReactivation bool,
|
|
revisionNumber int64,
|
|
) {
|
|
// Check if signals are enabled globally
|
|
if !enabled {
|
|
return
|
|
}
|
|
|
|
// Skip signal if matching confirmed the version is active or still draining.
|
|
if shouldSkipReactivation {
|
|
return
|
|
}
|
|
|
|
// Only process if we're pinning to a specific version
|
|
if !worker_versioning.OverrideIsPinned(override) {
|
|
return
|
|
}
|
|
|
|
pinnedVersion := worker_versioning.GetOverridePinnedVersion(override)
|
|
if pinnedVersion == nil {
|
|
return
|
|
}
|
|
|
|
// Send the signal asynchronously to avoid adding latency to the caller's request.
|
|
// Errors are logged by the signaler implementation (e.g. via convertAndRecordError). However,
|
|
// errors are not propagated to the caller as this is a fire-and-forget operation.
|
|
go func() {
|
|
signaler(context.Background(), namespaceEntry, pinnedVersion.GetDeploymentName(), pinnedVersion.GetBuildId(), revisionNumber) //nolint:errcheck
|
|
}()
|
|
}
|