Adds the composable monorepo template system that generates project skeletons with pluggable components (service, worker, app-react, app-astro, cli). Key changes: - Monorepo skeleton templates with shared pkg/, scripts/, and git hooks - Component templates (service, worker, app-react, app-astro, cli) with Dockerfiles, CI steps, and component.yaml manifests - Component domain model with validation and dependency resolution - Component handler endpoints for CRUD and composition - Template provider extended with BuildComposableProject and component assembly - Deployer extended with composable project deployment support - Handler timeout constants (TimeoutFastLookup through TimeoutLongRunning) - envutil package for centralized env var reads with defaults - api.DecodeJSON helper for standardized request body decoding - Standardized response helpers (WriteBadRequest, WriteNotFound, etc.) - Replaced fullstack-app cookbook with composable-app cookbook - Hardened handler timeouts, logging, and error responses across all handlers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package handlers
|
|
|
|
import "time"
|
|
|
|
// Handler operation timeout categories.
|
|
//
|
|
// Use these constants instead of inline magic numbers in context.WithTimeout calls.
|
|
// Choose the category that matches the operation's characteristics:
|
|
//
|
|
// - TimeoutFastLookup: simple reads, single-resource fetches, health checks
|
|
// - TimeoutStandard: single-service writes, K8s ops, DNS record ops
|
|
// - TimeoutHeavyWrite: multi-step writes with git operations
|
|
// - TimeoutOrchestration: multi-service coordination (create project, deploy)
|
|
// - TimeoutLongRunning: agent/command execution, async tasks
|
|
const (
|
|
// TimeoutFastLookup is for simple reads and lookups (DB queries, K8s get/list, health checks).
|
|
// 5 seconds. If a read takes longer, something is wrong.
|
|
TimeoutFastLookup = 5 * time.Second
|
|
|
|
// TimeoutLookup is for API lookups that may involve a remote call (Woodpecker list, template fetch).
|
|
// 10 seconds. Slightly more headroom for external API calls.
|
|
TimeoutLookup = 10 * time.Second
|
|
|
|
// TimeoutStandard is for single-service write operations (K8s apply, DNS create, git push).
|
|
// 30 seconds. Most write operations complete well within this.
|
|
TimeoutStandard = 30 * time.Second
|
|
|
|
// TimeoutHeavyWrite is for multi-step write operations (component add with git clone + template + push).
|
|
// 60 seconds. Git operations over network can be slow.
|
|
TimeoutHeavyWrite = 60 * time.Second
|
|
|
|
// TimeoutOrchestration is for operations that coordinate multiple services sequentially
|
|
// (project creation: repo + DNS + template + CI activation).
|
|
// 90 seconds. Longest synchronous handler operation.
|
|
TimeoutOrchestration = 90 * time.Second
|
|
|
|
// TimeoutLongRunning is for agent/command execution that streams output.
|
|
// 10 minutes. Claude Code commands can run extended operations.
|
|
TimeoutLongRunning = 10 * time.Minute
|
|
)
|