feat(ops-api/site-mappings): provision monitoring DB pool and readiness check
Open a separate pgx pool for the monitoring database, wire it into the SiteDomainMappingService, and surface its health in /readyz. Point compose at the dedicated monitoring-postgres service and align local/dev configs with the per-instance ports. Also reformat the site_domain_mapping types with gofmt while the files are touched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,9 +44,16 @@ func main() {
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
monitoringPool, err := postgres.NewPool(ctx, cfg.MonitoringDatabase)
|
||||
if err != nil {
|
||||
logger.Sugar().Fatalf("ops-api init monitoring postgres: %v", err)
|
||||
}
|
||||
defer monitoringPool.Close()
|
||||
|
||||
accountsRepo := repository.NewAccountRepository(pool)
|
||||
adminUsersRepo := repository.NewAdminUserRepository(pool)
|
||||
auditsRepo := repository.NewAuditRepository(pool)
|
||||
siteDomainMappingsRepo := repository.NewSiteDomainMappingRepository(monitoringPool)
|
||||
|
||||
ipRegionResolver, err := app.NewIPRegionResolver(cfg.IPRegion.V4XDBPath, cfg.IPRegion.V6XDBPath, logger)
|
||||
if err != nil {
|
||||
@@ -59,6 +66,7 @@ func main() {
|
||||
authSvc := app.NewAuthService(accountsRepo, auditSvc, issuer)
|
||||
accountSvc := app.NewAccountService(accountsRepo, auditSvc)
|
||||
adminUserSvc := app.NewAdminUserService(adminUsersRepo, auditSvc, cfg.AdminUsers.DefaultPlanCode)
|
||||
siteDomainMappingSvc := app.NewSiteDomainMappingService(siteDomainMappingsRepo, auditSvc)
|
||||
|
||||
if err := app.SeedDefaultAdmin(ctx, accountsRepo, app.DefaultAdminSeed{
|
||||
Username: cfg.DefaultAdmin.Username,
|
||||
@@ -75,14 +83,16 @@ func main() {
|
||||
engine := gin.New()
|
||||
|
||||
transport.RegisterRoutes(transport.Deps{
|
||||
Engine: engine,
|
||||
Logger: logger,
|
||||
DB: pool,
|
||||
Issuer: issuer,
|
||||
Auth: authSvc,
|
||||
Accounts: accountSvc,
|
||||
AdminUsers: adminUserSvc,
|
||||
Audits: auditSvc,
|
||||
Engine: engine,
|
||||
Logger: logger,
|
||||
DB: pool,
|
||||
MonitoringDB: monitoringPool,
|
||||
Issuer: issuer,
|
||||
Auth: authSvc,
|
||||
Accounts: accountSvc,
|
||||
AdminUsers: adminUserSvc,
|
||||
Audits: auditSvc,
|
||||
SiteDomains: siteDomainMappingSvc,
|
||||
})
|
||||
|
||||
addr := fmt.Sprintf(":%d", cfg.Server.Port)
|
||||
|
||||
Reference in New Issue
Block a user