Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
46
services/ota_update_go/controllers/health_check.go
Normal file
46
services/ota_update_go/controllers/health_check.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"otaupdate/services"
|
||||
"time"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/health"
|
||||
"github.com/fiskerinc/cloud-services/pkg/logger"
|
||||
)
|
||||
|
||||
func HealthCheck() {
|
||||
redis := health.NewRedisHealth(services.RedisClientPool())
|
||||
server := health.HealthCheckServer{}
|
||||
|
||||
err := server.Serve([]health.Config{
|
||||
{
|
||||
Name: "db",
|
||||
Check: health.NewPostgresCheck(services.GetDB().GetDBClient().GetConn()),
|
||||
Timeout: time.Second * 1,
|
||||
},
|
||||
{
|
||||
Name: "redis",
|
||||
Check: redis.Check,
|
||||
Timeout: time.Second * 1,
|
||||
Info: redis.RedisStatus,
|
||||
},
|
||||
{
|
||||
Name: "mongodb",
|
||||
Check: health.NewMongoDBCheck(getMongoClient),
|
||||
Timeout: time.Second * 1,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Send()
|
||||
}
|
||||
}
|
||||
|
||||
func getMongoClient() (health.MongoConnCheckInterface, error) {
|
||||
client, err := services.GetMongoClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conn := client.(health.MongoConnCheckInterface)
|
||||
return conn, nil
|
||||
}
|
||||
Reference in New Issue
Block a user