Files
zeekay 40351cce6f rip: delete temporal fork — native ZAP-only tasksd
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.
2026-04-26 14:06:21 -07:00

131 lines
4.8 KiB
Go

package migration
import (
"context"
"go.temporal.io/api/workflowservice/v1"
sdkworker "go.temporal.io/sdk/worker"
"go.temporal.io/sdk/workflow"
"go.temporal.io/server/api/adminservice/v1"
"go.temporal.io/server/chasm"
serverClient "go.temporal.io/server/client"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/headers"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/primitives"
"go.temporal.io/server/common/resource"
workercommon "go.temporal.io/server/service/worker/common"
"go.uber.org/fx"
)
type (
initParams struct {
fx.In
PersistenceConfig *config.Persistence
ExecutionManager persistence.ExecutionManager
NamespaceRegistry namespace.Registry
HistoryClient resource.HistoryClient
FrontendClient workflowservice.WorkflowServiceClient
ClientFactory serverClient.Factory
ClientBean serverClient.Bean
NamespaceReplicationQueue persistence.NamespaceReplicationQueue
TaskManager persistence.TaskManager
Logger log.Logger
MetricsHandler metrics.Handler
DynamicCollection *dynamicconfig.Collection
WorkflowVerifier WorkflowVerifier
ChasmRegistry *chasm.Registry
}
fxResult struct {
fx.Out
Component workercommon.WorkerComponent `group:"workerComponent"`
}
replicationWorkerComponent struct {
initParams
}
)
var Module = fx.Options(
fx.Provide(NewResult),
fx.Provide(workflowVerifierProvider),
)
func NewResult(params initParams) fxResult {
component := &replicationWorkerComponent{
initParams: params,
}
return fxResult{
Component: component,
}
}
func (wc *replicationWorkerComponent) RegisterWorkflow(registry sdkworker.Registry) {
registry.RegisterWorkflowWithOptions(CatchupWorkflow, workflow.RegisterOptions{Name: catchupWorkflowName})
registry.RegisterWorkflowWithOptions(ForceReplicationWorkflow, workflow.RegisterOptions{Name: forceReplicationWorkflowName})
registry.RegisterWorkflowWithOptions(ForceReplicationWorkflowV2, workflow.RegisterOptions{Name: forceReplicationWorkflowV2Name})
registry.RegisterWorkflowWithOptions(NamespaceHandoverWorkflow, workflow.RegisterOptions{Name: namespaceHandoverWorkflowName})
registry.RegisterWorkflowWithOptions(NamespaceHandoverWorkflowV2, workflow.RegisterOptions{Name: namespaceHandoverWorkflowV2Name})
registry.RegisterWorkflowWithOptions(ForceTaskQueueUserDataReplicationWorkflow, workflow.RegisterOptions{Name: forceTaskQueueUserDataReplicationWorkflow})
}
func (wc *replicationWorkerComponent) DedicatedWorkflowWorkerOptions() *workercommon.DedicatedWorkerOptions {
// Use default worker
return nil
}
func (wc *replicationWorkerComponent) RegisterActivities(registry sdkworker.Registry) {
registry.RegisterActivity(wc.activities())
}
func (wc *replicationWorkerComponent) DedicatedActivityWorkerOptions() *workercommon.DedicatedWorkerOptions {
return &workercommon.DedicatedWorkerOptions{
TaskQueue: primitives.MigrationActivityTQ,
Options: sdkworker.Options{
BackgroundActivityContext: headers.SetCallerType(context.Background(), headers.CallerTypePreemptable),
},
}
}
func workflowVerifierProvider() WorkflowVerifier {
return func(
_ context.Context,
_ *verifyReplicationTasksRequest,
_ adminservice.AdminServiceClient,
_ adminservice.AdminServiceClient,
_ *namespace.Namespace,
_ *ExecutionInfo,
_ *adminservice.DescribeMutableStateResponse,
) (verifyResult, error) {
return verifyResult{
status: verified,
}, nil
}
}
func (wc *replicationWorkerComponent) activities() *activities {
return &activities{
HistoryShardCount: wc.PersistenceConfig.NumHistoryShards,
executionManager: wc.ExecutionManager,
NamespaceRegistry: wc.NamespaceRegistry,
HistoryClient: wc.HistoryClient,
frontendClient: wc.FrontendClient,
clientFactory: wc.ClientFactory,
clientBean: wc.ClientBean,
namespaceReplicationQueue: wc.NamespaceReplicationQueue,
taskManager: wc.TaskManager,
Logger: wc.Logger,
MetricsHandler: wc.MetricsHandler,
forceReplicationMetricsHandler: wc.MetricsHandler.WithTags(metrics.WorkflowTypeTag(forceReplicationWorkflowName)),
generateMigrationTaskViaFrontend: dynamicconfig.WorkerGenerateMigrationTaskViaFrontend.Get(wc.DynamicCollection),
enableHistoryRateLimiter: dynamicconfig.WorkerEnableHistoryRateLimiter.Get(wc.DynamicCollection),
workflowVerifier: wc.WorkflowVerifier,
chasmRegistry: wc.ChasmRegistry,
}
}