fix: cache migration status
@@ -7,6 +7,8 @@ import (
"net/http"
"time"
+ "github.com/ory/x/popx"
+
"github.com/ory/x/httprouterx"
"github.com/rs/cors"
@@ -67,6 +69,7 @@ type RegistryBase struct {
cv *client.Validator
ctxer contextx.Contextualizer
hh *healthx.Handler
+ migrationStatus *popx.MigrationStatuses
kc *jwk.AEAD
cos consent.Strategy
writer herodot.Writer
@@ -265,6 +268,10 @@ func (m *RegistryBase) HealthHandler() *healthx.Handler {
return m.r.Ping()
},
"migrations": func(r *http.Request) error {
+ if m.migrationStatus != nil && !m.migrationStatus.HasPending() {
+ return nil
+ }
+
status, err := m.r.Persister().MigrationStatus(r.Context())
if err != nil {
return err
@@ -276,6 +283,7 @@ func (m *RegistryBase) HealthHandler() *healthx.Handler {
return err
}
+ m.migrationStatus = &status
return nil
},
})
