Adds the SciMesh coordinator: a durable task-queue server on PostgreSQL that owns all database access, with workers reaching it over HTTP only. Structured as a modular monolith following Clean Architecture: domain entities and their invariants, no I/O usecase business operations + repository/clock ports transport HTTP handlers, DTOs, auth, error mapping storage PostgreSQL repositories, transactions carried in context infra config, pool, clock, server, lease reaper Dependencies point strictly inward; domain imports nothing from the module. Working: layer wiring, routing, shared-token auth, access logging, request IDs, domain-error to status-code mapping, transactional boundaries, graceful shutdown (HTTP drain -> reaper stop -> pool close), migrations, and a Compose stack starting Postgres -> migrations -> coordinator. The domain is complete and covered by unit tests that need no database: lease ownership, stale attempts, idempotent result replay, retry budgets, and lease expiry. Repository methods are stubs returning ErrNotImplemented (HTTP 501). The SQL for atomic claiming (FOR UPDATE SKIP LOCKED) and for lease expiry is written and ready to wire up. See coordinator/ARCHITECTURE.md for the layer map and a request traced through every layer.
52 lines
936 B
Go
52 lines
936 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 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
|
|
}
|