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.
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
package queues
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
persistencespb "go.temporal.io/server/api/persistence/v1"
|
|
"go.temporal.io/server/common/cluster"
|
|
"go.temporal.io/server/common/log"
|
|
"go.temporal.io/server/common/metrics"
|
|
"go.temporal.io/server/common/persistence"
|
|
"go.temporal.io/server/service/history/shard"
|
|
"go.temporal.io/server/service/history/tasks"
|
|
"go.temporal.io/server/service/history/tests"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
type (
|
|
immediateQueueSuite struct {
|
|
suite.Suite
|
|
*require.Assertions
|
|
|
|
controller *gomock.Controller
|
|
mockShard *shard.ContextTest
|
|
mockExecutionManager *persistence.MockExecutionManager
|
|
|
|
immediateQueue *immediateQueue
|
|
}
|
|
)
|
|
|
|
func TestImmediateQueueSuite(t *testing.T) {
|
|
s := new(immediateQueueSuite)
|
|
suite.Run(t, s)
|
|
}
|
|
|
|
func (s *immediateQueueSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
|
|
s.controller = gomock.NewController(s.T())
|
|
s.mockShard = shard.NewTestContext(
|
|
s.controller,
|
|
&persistencespb.ShardInfo{
|
|
ShardId: 0,
|
|
RangeId: 1,
|
|
Owner: "test-shard-owner",
|
|
},
|
|
tests.NewDynamicConfig(),
|
|
)
|
|
s.mockExecutionManager = s.mockShard.Resource.ExecutionMgr
|
|
s.mockShard.Resource.ClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
|
|
|
|
s.immediateQueue = NewImmediateQueue(
|
|
s.mockShard,
|
|
tasks.CategoryTransfer,
|
|
nil, // scheduler
|
|
nil, // rescheduler
|
|
&testQueueOptions,
|
|
NewReaderPriorityRateLimiter(
|
|
func() float64 { return 10 },
|
|
1,
|
|
),
|
|
GrouperNamespaceID{},
|
|
log.NewTestLogger(),
|
|
metrics.NoopMetricsHandler,
|
|
nil, // execuable factory
|
|
nil, // taskPostProcessor
|
|
)
|
|
}
|
|
|
|
func (s *immediateQueueSuite) TearDownTest() {
|
|
s.controller.Finish()
|
|
}
|
|
|
|
func (s *immediateQueueSuite) TestPaginationFnProvider_ShardOwnershipLost() {
|
|
paginationFnProvider := s.immediateQueue.paginationFnProvider
|
|
|
|
s.mockExecutionManager.EXPECT().GetHistoryTasks(gomock.Any(), gomock.Any()).Return(nil, &persistence.ShardOwnershipLostError{
|
|
ShardID: s.mockShard.GetShardID(),
|
|
}).Times(1)
|
|
|
|
paginationFn := paginationFnProvider(NewRandomRange())
|
|
_, _, err := paginationFn(nil)
|
|
s.True(shard.IsShardOwnershipLostError(err))
|
|
|
|
// make sure shard is also marked as invalid
|
|
s.False(s.mockShard.IsValid())
|
|
}
|