[feature] Add healthcheck endpoints /livez and /readyz (#2783)

* [feature] Add healthcheck endpoints `/livez` and `/readyz`

* use select that returns no data
This commit is contained in:
tobi 2024-03-25 18:05:14 +01:00 committed by GitHub
commit b7b42e832a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 328 additions and 4 deletions

View file

@ -124,8 +124,14 @@ func (b *basicDB) DropTable(ctx context.Context, i interface{}) error {
return err
}
func (b *basicDB) IsHealthy(ctx context.Context) error {
return b.db.PingContext(ctx)
func (b *basicDB) Ready(ctx context.Context) error {
if _, err := b.db.
NewRaw("SELECT NULL FROM ? LIMIT 0", bun.Ident("instances")).
Exec(ctx); err != nil {
return err
}
return nil
}
func (b *basicDB) Close() error {