Skip to content

Commit

Permalink
temporarily take out health check
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-goodisman committed Apr 19, 2024
1 parent af4b821 commit dc424b1
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"

"github.com/tulip/oplogtoredis/lib/config"
"github.com/tulip/oplogtoredis/lib/log"
Expand Down Expand Up @@ -253,30 +252,30 @@ func createRedisClients() ([]redis.UniversalClient, error) {
return ret, nil
}

func makeHTTPServer(clients []redis.UniversalClient, mongo *mongo.Client) *http.Server {
func makeHTTPServer( /*clients []redis.UniversalClient, mongo *mongo.Client*/ ) *http.Server {
mux := http.NewServeMux()

mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
redisOK := true
for _, redis := range clients {
redisErr := redis.Ping(context.Background()).Err()
redisOK = (redisOK && (redisErr == nil))
if !redisOK {
log.Log.Errorw("Error connecting to Redis during healthz check",
"error", redisErr)
}
}

ctx, cancel := context.WithTimeout(context.Background(), config.MongoConnectTimeout())
defer cancel()

mongoErr := mongo.Ping(ctx, readpref.Primary())
mongoOK := mongoErr == nil

if !mongoOK {
log.Log.Errorw("Error connecting to Mongo during healthz check",
"error", mongoErr)
}
// for _, redis := range clients {
// redisErr := redis.Ping(context.Background()).Err()
// redisOK = (redisOK && (redisErr == nil))
// if !redisOK {
// log.Log.Errorw("Error connecting to Redis during healthz check",
// "error", redisErr)
// }
// }

// ctx, cancel := context.WithTimeout(context.Background(), config.MongoConnectTimeout())
// defer cancel()

// mongoErr := mongo.Ping(ctx, readpref.Primary())
mongoOK := true //mongoErr == nil

// if !mongoOK {
// log.Log.Errorw("Error connecting to Mongo during healthz check",
// "error", mongoErr)
// }

if mongoOK && redisOK {
w.WriteHeader(http.StatusOK)
Expand Down

0 comments on commit dc424b1

Please sign in to comment.