mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +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.
95 lines
2.7 KiB
Go
95 lines
2.7 KiB
Go
package visibility
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
|
|
"go.temporal.io/api/serviceerror"
|
|
"go.temporal.io/server/api/visibilityservice/v1"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/common/namespace"
|
|
"go.temporal.io/server/common/persistence/visibility/manager"
|
|
)
|
|
|
|
type ChasmVisibilityManager struct {
|
|
registry *chasm.Registry
|
|
nsRegistry namespace.Registry
|
|
visibilityMgr manager.VisibilityManager
|
|
}
|
|
|
|
var _ chasm.VisibilityManager = (*ChasmVisibilityManager)(nil)
|
|
|
|
func NewChasmVisibilityManager(
|
|
registry *chasm.Registry,
|
|
nsRegistry namespace.Registry,
|
|
visibilityMgr manager.VisibilityManager,
|
|
) *ChasmVisibilityManager {
|
|
return &ChasmVisibilityManager{
|
|
registry: registry,
|
|
nsRegistry: nsRegistry,
|
|
visibilityMgr: visibilityMgr,
|
|
}
|
|
}
|
|
|
|
func ChasmVisibilityManagerProvider(
|
|
registry *chasm.Registry,
|
|
nsRegistry namespace.Registry,
|
|
visibilityMgr manager.VisibilityManager,
|
|
) chasm.VisibilityManager {
|
|
return NewChasmVisibilityManager(registry, nsRegistry, visibilityMgr)
|
|
}
|
|
|
|
// ListExecutions implements the Engine interface for visibility queries.
|
|
func (e *ChasmVisibilityManager) ListExecutions(
|
|
ctx context.Context,
|
|
archetypeType reflect.Type,
|
|
request *chasm.ListExecutionsRequest,
|
|
) (*visibilityservice.ListChasmExecutionsResponse, error) {
|
|
archetypeID, ok := e.registry.ArchetypeIDOf(archetypeType)
|
|
if !ok {
|
|
return nil, serviceerror.NewInternal("unknown chasm component type: " + archetypeType.String())
|
|
}
|
|
|
|
namespaceID, err := e.nsRegistry.GetNamespaceID(namespace.Name(request.NamespaceName))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
visReq := &visibilityservice.ListChasmExecutionsRequest{
|
|
ArchetypeId: archetypeID,
|
|
NamespaceId: namespaceID.String(),
|
|
Namespace: request.NamespaceName,
|
|
PageSize: int32(request.PageSize),
|
|
NextPageToken: request.NextPageToken,
|
|
Query: request.Query,
|
|
}
|
|
|
|
return e.visibilityMgr.ListChasmExecutions(ctx, visReq)
|
|
}
|
|
|
|
// CountExecutions implements the Engine interface for visibility queries.
|
|
func (e *ChasmVisibilityManager) CountExecutions(
|
|
ctx context.Context,
|
|
archetypeType reflect.Type,
|
|
request *chasm.CountExecutionsRequest,
|
|
) (*visibilityservice.CountChasmExecutionsResponse, error) {
|
|
archetypeID, ok := e.registry.ArchetypeIDOf(archetypeType)
|
|
if !ok {
|
|
return nil, serviceerror.NewInternal("unknown chasm component type: " + archetypeType.String())
|
|
}
|
|
|
|
namespaceID, err := e.nsRegistry.GetNamespaceID(namespace.Name(request.NamespaceName))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
visReq := &visibilityservice.CountChasmExecutionsRequest{
|
|
ArchetypeId: archetypeID,
|
|
NamespaceId: namespaceID.String(),
|
|
Namespace: request.NamespaceName,
|
|
Query: request.Query,
|
|
}
|
|
|
|
return e.visibilityMgr.CountChasmExecutions(ctx, visReq)
|
|
}
|