Align the coordinator with the master PLAN.md (CTX-00, CTX-04) and harden process startup. - CTX-00: freeze docs/api-contract.md as the v1 source of truth for the Go coordinator and Python worker. - CTX-04: worker registry — workers table (migration 0002), domain.Worker, RegisterWorker use case, WorkerRepository, and POST /workers/register. - Contract alignment: claim uses `capabilities` (was `workloads`), COORDINATOR_TOKEN env (WORKER_AUTH_TOKEN kept as fallback), and GET /health now reports database readiness (503 when the DB is down). - Logging: logs are teed to stdout and an optional rotated file (LOG_FILE) via lumberjack, so they survive a container rebuild. - Startup resilience: the initial DB connection is retried with backoff, so the coordinator waits for Postgres to boot instead of crash-looping.
57 lines
1017 B
Go
57 lines
1017 B
Go
package usecase
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
// Use-case boundary types. Adapters map their wire formats onto these, so the
|
|
// HTTP shape can change without touching business code.
|
|
|
|
type CreateJobInput struct {
|
|
Workload string
|
|
InputURI string
|
|
Parameters map[string]any
|
|
Chunks []ChunkInput
|
|
}
|
|
|
|
type ChunkInput struct {
|
|
ChunkIndex int
|
|
Workload string
|
|
InputURI string
|
|
InputSHA256 string
|
|
Parameters map[string]any
|
|
MaxAttempts int
|
|
}
|
|
|
|
type RegisterWorkerInput struct {
|
|
Name string
|
|
Capabilities []string
|
|
}
|
|
|
|
type ClaimTaskInput struct {
|
|
WorkerID string
|
|
Workloads []string
|
|
}
|
|
|
|
type RenewLeaseInput struct {
|
|
TaskID uuid.UUID
|
|
WorkerID string
|
|
Attempt int
|
|
}
|
|
|
|
type CompleteTaskInput struct {
|
|
TaskID uuid.UUID
|
|
WorkerID string
|
|
Attempt int
|
|
ResultURI string
|
|
ResultSHA256 string
|
|
Metrics map[string]any
|
|
}
|
|
|
|
type FailTaskInput struct {
|
|
TaskID uuid.UUID
|
|
WorkerID string
|
|
Attempt int
|
|
ErrorCode string
|
|
ErrorMessage string
|
|
Retryable bool
|
|
}
|