feat: establish Orbit models, migrations and development baseline

This commit is contained in:
2026-09-17 07:04:21 +08:00
commit 4f2935e36f
84 changed files with 4915 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
// Package httpserver exposes bootstrap health endpoints only. Task, workflow,
// authentication and WebSocket APIs will be implemented in subsequent slices.
package httpserver
import (
"context"
"encoding/json"
"net/http"
"time"
)
type Checker func(context.Context) error
func New(addr string, ready Checker) *http.Server {
mux := http.NewServeMux()
write := func(w http.ResponseWriter, status int, body map[string]string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(body)
}
mux.HandleFunc("GET /health/live", func(w http.ResponseWriter, r *http.Request) {
write(w, http.StatusOK, map[string]string{"status": "alive"})
})
mux.HandleFunc("GET /health/ready", func(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
defer cancel()
if ready == nil || ready(ctx) != nil {
write(w, http.StatusServiceUnavailable, map[string]string{"status": "not_ready"})
return
}
write(w, http.StatusOK, map[string]string{"status": "ready", "scope": "database_and_schema"})
})
return &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, IdleTimeout: 60 * time.Second, MaxHeaderBytes: 16 << 10}
}