()
| 126 | } |
| 127 | |
| 128 | func (r *RegistryDefault) HealthHandler() *healthx.Handler { |
| 129 | if r.healthH != nil { |
| 130 | return r.healthH |
| 131 | } |
| 132 | |
| 133 | h := healthx.ReadyCheckers{ |
| 134 | "database": func(req *http.Request) error { |
| 135 | return r.Persister().Connection(req.Context()).Store.PingContext(req.Context()) |
| 136 | }, |
| 137 | "migrations": func(req *http.Request) error { |
| 138 | mb, err := r.MigrationBox(req.Context()) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
| 142 | status, err := mb.Status(req.Context()) |
| 143 | if err != nil { |
| 144 | return err |
| 145 | } |
| 146 | |
| 147 | if status.HasPending() { |
| 148 | return errors.Errorf("migrations have not yet been fully applied") |
| 149 | } |
| 150 | return nil |
| 151 | }, |
| 152 | } |
| 153 | maps.Copy(h, r.healthReadyCheckers) // possibly override default checkers |
| 154 | |
| 155 | r.healthH = healthx.NewHandler(r.Writer(), config.Version, h) |
| 156 | |
| 157 | return r.healthH |
| 158 | } |
| 159 | |
| 160 | func (r *RegistryDefault) HealthServer() *health.Server { |
| 161 | if r.healthServer == nil { |
no test coverage detected