How palantir/witchcraft-go-server works
Main Components
a. Core Server Components:
• HTTP/HTTPS Server (with TLS support)
• Management Server (optional, on separate port)
• Router System (wrouter)
• Middleware Chain
• Configuration System (Install & Runtime)
b. Supporting Systems:
• Logging System
• Metrics System
• Tracing System
• Health Check System
• Diagnostic System
Component Relationships
Client Requests
• ↓
TLS Termination
• ↓
Request Middleware Chain
• ↓
Router (wrouter)
• ↓
Route Middleware Chain
• ↓
Application Handlers
Supporting Systems (Connected to Main Flow):
• Logging System → Log Files/stdout
• Metrics System → Metrics Collection
• Tracing System → Trace Collection
• Health Check System → Status Endpoints
• Configuration System → Install & Runtime Config
Specific Implementation Details to Highlight
a. Configuration System:
• Separation between Install Config (static) and Runtime Config (refreshable)
• File-based config sources (var/conf/install.yml, var/conf/runtime.yml)
• Encrypted config value support
b. Middleware Architecture:
• Two types of middleware (Request and Route)
• Built-in middleware components (panic recovery, logging, metrics)
• Where custom middleware can be inserted
c. Observability Stack:
• Various log types (service, request, metric, trace)
• Metrics collection and emission flow
• Trace ID propagation through the system
d. Health & Diagnostics:
• Health check endpoints (/status/*)
• Diagnostic endpoints (/debug/diagnostic/*)
• Management server separation (if enabled)
Key Interfaces to Document
• Server initialization interface
• Router registration interface
• Middleware interfaces
• Configuration interfaces (Install & Runtime)
• Refreshable interface for runtime config
Additional Elements
• Annotations for key configuration points
• Signal handling (SIGQUIT, SIGTERM, SIGINT)
• Where custom application code integrates