mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +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.
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
package queues
|
|
|
|
import (
|
|
"go.temporal.io/server/common/predicates"
|
|
"go.temporal.io/server/service/history/tasks"
|
|
)
|
|
|
|
// Grouper groups tasks and constructs predicates for those groups.
|
|
type Grouper interface {
|
|
// Key returns the group key for a given task.
|
|
Key(task tasks.Task) (key any)
|
|
// Predicate constructs a prdicate from a slice of keys.
|
|
Predicate(keys []any) tasks.Predicate
|
|
}
|
|
|
|
type GrouperNamespaceID struct {
|
|
}
|
|
|
|
func (GrouperNamespaceID) Key(task tasks.Task) (key any) {
|
|
return task.GetNamespaceID()
|
|
}
|
|
|
|
func (GrouperNamespaceID) Predicate(keys []any) tasks.Predicate {
|
|
pendingNamespaceIDs := make([]string, len(keys))
|
|
for i, namespaceID := range keys {
|
|
// Assume predicate is only called with keys returned from GrouperNamespaceID.Key()
|
|
pendingNamespaceIDs[i] = namespaceID.(string)
|
|
}
|
|
return tasks.NewNamespacePredicate(pendingNamespaceIDs)
|
|
}
|
|
|
|
var _ Grouper = GrouperNamespaceID{}
|
|
|
|
type GrouperStateMachineNamespaceIDAndDestination struct {
|
|
}
|
|
|
|
func (g GrouperStateMachineNamespaceIDAndDestination) Key(task tasks.Task) (key any) {
|
|
return g.KeyTyped(task)
|
|
}
|
|
|
|
func (GrouperStateMachineNamespaceIDAndDestination) KeyTyped(task tasks.Task) (key tasks.TaskGroupNamespaceIDAndDestination) {
|
|
destGetter, ok := task.(tasks.HasDestination)
|
|
var dest string
|
|
if ok {
|
|
dest = destGetter.GetDestination()
|
|
}
|
|
smtGetter, ok := task.(tasks.HasOutboundTaskGroup)
|
|
var smt string
|
|
if ok {
|
|
smt = smtGetter.OutboundTaskGroup()
|
|
}
|
|
return tasks.TaskGroupNamespaceIDAndDestination{
|
|
TaskGroup: smt,
|
|
NamespaceID: task.GetNamespaceID(),
|
|
Destination: dest,
|
|
}
|
|
}
|
|
|
|
func (GrouperStateMachineNamespaceIDAndDestination) Predicate(keys []any) tasks.Predicate {
|
|
if len(keys) == 0 {
|
|
return predicates.Empty[tasks.Task]()
|
|
}
|
|
groups := make([]tasks.TaskGroupNamespaceIDAndDestination, len(keys))
|
|
for i, anyKey := range keys {
|
|
// Assume predicate is only called with keys returned from OutboundTaskGroupNamespaceIDAndDestination.Key()
|
|
key := anyKey.(tasks.TaskGroupNamespaceIDAndDestination)
|
|
groups[i] = key
|
|
}
|
|
return tasks.NewOutboundTaskPredicate(groups)
|
|
}
|
|
|
|
var _ Grouper = GrouperStateMachineNamespaceIDAndDestination{}
|