mirror of
https://github.com/hanzoai/base.git
synced 2026-10-21 03:41:50 +00:00
Base's own registry was already org-native in every method — OrgDB(orgID), HasOrg(orgID), orgDir(orgID) — and only the type names said tenant. So this is the vocabulary catching up with the code, not a change of behaviour. TenantRegistry -> Bases app.Bases().OrgDB(org) TenantConfig -> BasesConfig MultiTenant -> PerOrg it enables per-org databases; say that MULTI_TENANT -> MULTI_BASE core/tenant.go -> core/bases.go Tenant was the wrong noun twice over: it is the multi-tenancy word, and this product's unit is the thing a customer creates per org — a Base. Identity here is org, user, project, and nothing else. The UI never said it; this was Go-side only. 64 packages green. One test was collateral and is fixed rather than renamed: TestToHTTPHeader asserts a pure snake_case-to-Header-Case transform, so rewriting its EXPECTED value while its input stayed "tenant_id" made it assert something false. The case is dropped — org_id already covers that transform.
40 lines
989 B
Go
40 lines
989 B
Go
package tasks
|
|
|
|
import (
|
|
"github.com/hanzoai/tasks/pkg/sdk/client"
|
|
sdkworker "github.com/hanzoai/tasks/pkg/sdk/worker"
|
|
)
|
|
|
|
// Worker runs an embedded Temporal worker that polls a task queue
|
|
// and executes workflows and activities in-process.
|
|
type Worker struct {
|
|
worker sdkworker.Worker
|
|
queue string
|
|
}
|
|
|
|
// NewWorker creates a worker for a specific task queue.
|
|
// For per-org deployments, each org/space can have its own queue.
|
|
func NewWorker(c client.Client, queue string) *Worker {
|
|
w := sdkworker.New(c, queue, sdkworker.Options{})
|
|
|
|
// Register all workflow types.
|
|
w.RegisterWorkflow(AgentTaskWorkflow)
|
|
w.RegisterWorkflow(PipelineWorkflow)
|
|
w.RegisterWorkflow(FanOutWorkflow)
|
|
|
|
// Register activities.
|
|
w.RegisterActivity(ExecuteTaskActivity)
|
|
|
|
return &Worker{worker: w, queue: queue}
|
|
}
|
|
|
|
// Start begins polling the task queue.
|
|
func (tw *Worker) Start() error {
|
|
return tw.worker.Start()
|
|
}
|
|
|
|
// Stop gracefully shuts down the worker.
|
|
func (tw *Worker) Stop() {
|
|
tw.worker.Stop()
|
|
}
|