30 lines
597 B
Go
30 lines
597 B
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"hfb_sys/backend/internal/handler"
|
|
)
|
|
|
|
func newReadinessChecks(deps Dependencies) map[string]handler.ReadinessCheck {
|
|
return map[string]handler.ReadinessCheck{
|
|
"mysql": func(ctx context.Context) error {
|
|
if deps.DB == nil {
|
|
return errors.New("mysql unavailable")
|
|
}
|
|
sqlDB, err := deps.DB.DB()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return sqlDB.PingContext(ctx)
|
|
},
|
|
"redis": func(ctx context.Context) error {
|
|
if deps.Redis == nil {
|
|
return errors.New("redis unavailable")
|
|
}
|
|
return deps.Redis.Ping(ctx).Err()
|
|
},
|
|
}
|
|
}
|