Files
tasks/chasm/lib/tests/tasks.go
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

80 lines
1.8 KiB
Go

package tests
import (
"context"
"go.temporal.io/server/chasm"
"go.temporal.io/server/chasm/lib/tests/gen/testspb/v1"
)
type PayloadTTLPureTaskHandler struct{ chasm.PureTaskHandlerBase }
func (h *PayloadTTLPureTaskHandler) Execute(
mutableContext chasm.MutableContext,
store *PayloadStore,
_ chasm.TaskAttributes,
task *testspb.TestPayloadTTLPureTask,
) error {
if err := assertContextValue(mutableContext); err != nil {
return err
}
_, err := store.RemovePayload(mutableContext, task.PayloadKey)
return err
}
func (h *PayloadTTLPureTaskHandler) Validate(
chasmContext chasm.Context,
store *PayloadStore,
attributes chasm.TaskAttributes,
task *testspb.TestPayloadTTLPureTask,
) (bool, error) {
return validateTask(chasmContext, store, attributes, task.PayloadKey)
}
type PayloadTTLSideEffectTaskHandler struct {
chasm.SideEffectTaskHandlerBase[*testspb.TestPayloadTTLSideEffectTask]
}
func (h *PayloadTTLSideEffectTaskHandler) Execute(
ctx context.Context,
ref chasm.ComponentRef,
_ chasm.TaskAttributes,
task *testspb.TestPayloadTTLSideEffectTask,
) error {
_, _, err := chasm.UpdateComponent(
ctx,
ref,
(*PayloadStore).RemovePayload,
task.PayloadKey,
)
return err
}
func (h *PayloadTTLSideEffectTaskHandler) Validate(
chasmContext chasm.Context,
store *PayloadStore,
attributes chasm.TaskAttributes,
task *testspb.TestPayloadTTLSideEffectTask,
) (bool, error) {
return validateTask(chasmContext, store, attributes, task.PayloadKey)
}
func validateTask(
chasmContext chasm.Context,
store *PayloadStore,
attributes chasm.TaskAttributes,
payloadKey string,
) (bool, error) {
if err := assertContextValue(chasmContext); err != nil {
return false, err
}
expirationTime, ok := store.State.ExpirationTimes[payloadKey]
if !ok {
return false, nil
}
return !expirationTime.AsTime().After(attributes.ScheduledTime), nil
}