Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
42
services/optimus/controllers/health_check.go
Normal file
42
services/optimus/controllers/health_check.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/services/optimus/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/health"
|
||||
"github.com/fiskerinc/cloud-services/pkg/logger"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var mismatchTypeError = errors.New("mismatch type error")
|
||||
|
||||
func HealthCheck() {
|
||||
server := health.HealthCheckServer{}
|
||||
err := server.Serve([]health.Config{
|
||||
{
|
||||
Name: "kafka",
|
||||
Check: health.NewKafkaCheck(getKafkaConsumer),
|
||||
Timeout: time.Second * 1,
|
||||
Vital: true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Send()
|
||||
}
|
||||
}
|
||||
|
||||
func getKafkaConsumer() (health.KafkaConnCheckInterface, error) {
|
||||
client, err := services.GetKafkaConsumer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conn, ok := client.(health.KafkaConnCheckInterface)
|
||||
if !ok {
|
||||
return nil, errors.WithStack(mismatchTypeError)
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
Reference in New Issue
Block a user