diff --git a/driver/registry_sql.go b/driver/registry_sql.go index 76159e4c80..7cef650f95 100644 --- a/driver/registry_sql.go +++ b/driver/registry_sql.go @@ -247,8 +247,12 @@ func (m *RegistrySQL) alwaysCanHandle(dsn string) bool { return s == dbal.DriverMySQL || s == dbal.DriverPostgreSQL || s == dbal.DriverCockroachDB } +func (m *RegistrySQL) PingContext(ctx context.Context) error { + return m.Persister().Ping(ctx) +} + func (m *RegistrySQL) Ping() error { - return m.Persister().Ping() + return m.PingContext(context.Background()) } func (m *RegistrySQL) ClientManager() client.Manager { @@ -439,8 +443,8 @@ func (m *RegistrySQL) GrantValidator() *trust.GrantValidator { func (m *RegistrySQL) HealthHandler() *healthx.Handler { if m.hh == nil { m.hh = healthx.NewHandler(m.Writer(), m.buildVersion, healthx.ReadyCheckers{ - "database": func(_ *http.Request) error { - return m.Ping() + "database": func(r *http.Request) error { + return m.PingContext(r.Context()) }, "migrations": func(r *http.Request) error { if m.migrationStatus != nil && !m.migrationStatus.HasPending() { diff --git a/go.mod b/go.mod index 26adbfc96c..2fcfa4c698 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.5 replace github.com/ory/hydra-client-go/v2 => ./internal/httpclient -replace github.com/gobuffalo/pop/v6 => github.com/ory/pop/v6 v6.2.0 +replace github.com/gobuffalo/pop/v6 => github.com/ory/pop/v6 v6.2.1-0.20241121111754-e5dfc0f3344b // Bump Fosite to https://github.com/ory/fosite/tree/hperl/v0.47.0%2B168636f, which contains // https://github.com/ory/fosite/commit/b40b1cbb1997e2160eaaf97fb6f73960db4c6118 and https://github.com/ory/fosite/pull/833/commits/eab241e153a4c97abe2e4c6e654f20b9ae206473 on top of the latest release. diff --git a/go.sum b/go.sum index 5f7a2ba760..417e0fd5cf 100644 --- a/go.sum +++ b/go.sum @@ -392,8 +392,8 @@ github.com/ory/jsonschema/v3 v3.0.8 h1:Ssdb3eJ4lDZ/+XnGkvQS/te0p+EkolqwTsDOCxr/F github.com/ory/jsonschema/v3 v3.0.8/go.mod h1:ZPzqjDkwd3QTnb2Z6PAS+OTvBE2x5i6m25wCGx54W/0= github.com/ory/kratos-client-go v1.2.1 h1:Q3T/adfAfAkHFcV1LGLnwz4QkY6ghBdX9zde5T8uO/4= github.com/ory/kratos-client-go v1.2.1/go.mod h1:WiQYlrqW4Atj6Js7oDN5ArbZxo0nTO2u/e1XaDv2yMI= -github.com/ory/pop/v6 v6.2.0 h1:hRFOGAOEHw91kUHQ32k5NHqCkcHrRou/romvrJP1w0E= -github.com/ory/pop/v6 v6.2.0/go.mod h1:okVAYKGtgunD/wbW3NGhZTndJCS+6FqO+cA89rQ4doc= +github.com/ory/pop/v6 v6.2.1-0.20241121111754-e5dfc0f3344b h1:BIzoOe2/wynZBQak1po0tzgvARseIKsR2bF6b+SZoKE= +github.com/ory/pop/v6 v6.2.1-0.20241121111754-e5dfc0f3344b/go.mod h1:okVAYKGtgunD/wbW3NGhZTndJCS+6FqO+cA89rQ4doc= github.com/ory/x v0.0.668 h1:HfJgq+vRwC6ptzc3+Y1VFpo9zc8eXHEtX24qxAPqr5s= github.com/ory/x v0.0.668/go.mod h1:0Av1u/Gh7WXCrEDJJnySAJrDzluaWllOfl5zqf9Dky8= github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= diff --git a/persistence/definitions.go b/persistence/definitions.go index 5cd9c9a3f1..ac9076eb2d 100644 --- a/persistence/definitions.go +++ b/persistence/definitions.go @@ -34,7 +34,7 @@ type ( PrepareMigration(context.Context) error Connection(context.Context) *pop.Connection Transaction(context.Context, func(ctx context.Context, c *pop.Connection) error) error - Ping() error + Ping(context.Context) error Networker } Provider interface { diff --git a/persistence/sql/persister.go b/persistence/sql/persister.go index 98161c55cf..4b3b3fb944 100644 --- a/persistence/sql/persister.go +++ b/persistence/sql/persister.go @@ -178,9 +178,8 @@ func (p *Persister) Connection(ctx context.Context) *pop.Connection { return popx.GetConnection(ctx, p.conn) } -func (p *Persister) Ping() error { - type pinger interface{ Ping() error } - return p.conn.Store.(pinger).Ping() +func (p *Persister) Ping(ctx context.Context) error { + return p.conn.Store.SQLDB().PingContext(ctx) } func (p *Persister) mustSetNetwork(nid uuid.UUID, v interface{}) interface{} {