23 lines
365 B
Go
23 lines
365 B
Go
package health
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type GetMongoClientFunc func() (MongoConnCheckInterface, error)
|
|
|
|
func NewMongoDBCheck(fn GetMongoClientFunc) CheckFunc {
|
|
return func(ctx context.Context) error {
|
|
conn, err := fn()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return conn.Ping(ctx)
|
|
}
|
|
}
|
|
|
|
type MongoConnCheckInterface interface {
|
|
Ping(ctx context.Context) error
|
|
}
|