MCPcopy
hub / github.com/ory/keto / HealthHandler

Method HealthHandler

internal/driver/registry_default.go:128–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128func (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
160func (r *RegistryDefault) HealthServer() *health.Server {
161 if r.healthServer == nil {

Callers 3

ReadRouterMethod · 0.95
WriteRouterMethod · 0.95
OPLSyntaxRouterMethod · 0.95

Calls 7

PersisterMethod · 0.95
MigrationBoxMethod · 0.95
WriterMethod · 0.95
HasPendingMethod · 0.80
ConnectionMethod · 0.65
StatusMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected