feat(backend): add bootstrap package with startup validation and DB probe#9
Conversation
…robe Introduces internal/bootstrap with an App struct that loads config, validates required env vars, and probes Postgres with exponential backoff before the HTTP server starts. main.go and server.go updated to wire through *bootstrap.App instead of reading env vars independently.
|
Warning Review limit reached
More reviews will be available in 39 minutes and 24 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
internal/bootstrappackage with anAppstruct that owns all shared, validated dependencies (*sql.DB,Config,*slog.Logger)bootstrap.Run(ctx)validates requiredBLUEPRINT_DB_*env vars, opens the DB connection, and probes Postgres with up to 5 attempts using full-jitter exponential backoff (500ms base → 16s cap, 15s per-attempt deadline to handle Neon cold starts)server.NewServerupdated to accept*bootstrap.Appinstead of reading env vars itself; startup failures exit with code 1 and a message to stderrmain.gofollows the signal/bootstrap/serve pattern from the reference implementationTest plan
cd backend && make docker-run && make watch— server starts, bootstrap logs show config valid + postgres readyBLUEPRINT_DB_HOST) — process exits 1 with config error before attempting a connectiongo vet ./...andgo build ./...pass cleanly