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:
@@ -11,15 +11,16 @@ import (
|
||||
)
|
||||
|
||||
type Deps struct {
|
||||
Engine *gin.Engine
|
||||
Logger *zap.Logger
|
||||
DB *pgxpool.Pool
|
||||
Issuer *app.TokenIssuer
|
||||
Auth *app.AuthService
|
||||
Accounts *app.AccountService
|
||||
AdminUsers *app.AdminUserService
|
||||
Audits *app.AuditService
|
||||
SiteDomains *app.SiteDomainMappingService
|
||||
Engine *gin.Engine
|
||||
Logger *zap.Logger
|
||||
DB *pgxpool.Pool
|
||||
MonitoringDB *pgxpool.Pool
|
||||
Issuer *app.TokenIssuer
|
||||
Auth *app.AuthService
|
||||
Accounts *app.AccountService
|
||||
AdminUsers *app.AdminUserService
|
||||
Audits *app.AuditService
|
||||
SiteDomains *app.SiteDomainMappingService
|
||||
}
|
||||
|
||||
func RegisterRoutes(d Deps) {
|
||||
@@ -38,6 +39,12 @@ func RegisterRoutes(d Deps) {
|
||||
response.Error(c, response.ErrServiceUnavailable(50301, "postgres_unavailable", "数据库不可达"))
|
||||
return
|
||||
}
|
||||
if d.MonitoringDB != nil {
|
||||
if err := d.MonitoringDB.Ping(c.Request.Context()); err != nil {
|
||||
response.Error(c, response.ErrServiceUnavailable(50303, "monitoring_postgres_unavailable", "监控数据库不可达"))
|
||||
return
|
||||
}
|
||||
}
|
||||
response.Success(c, gin.H{"status": "ready"})
|
||||
})
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
type siteDomainMappingRequest struct {
|
||||
RegistrableDomain string `json:"registrable_domain" binding:"required"`
|
||||
SiteKey string `json:"site_key"`
|
||||
SiteName string `json:"site_name" binding:"required"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
SiteKey string `json:"site_key"`
|
||||
SiteName string `json:"site_name" binding:"required"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type setSiteDomainMappingActiveRequest struct {
|
||||
@@ -118,9 +118,9 @@ func (r siteDomainMappingRequest) toInput() app.SiteDomainMappingInput {
|
||||
}
|
||||
return app.SiteDomainMappingInput{
|
||||
RegistrableDomain: r.RegistrableDomain,
|
||||
SiteKey: r.SiteKey,
|
||||
SiteName: r.SiteName,
|
||||
IsActive: active,
|
||||
SiteKey: r.SiteKey,
|
||||
SiteName: r.SiteName,
|
||||
IsActive: active,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user