func (m *Mongo) IsClientSafe(context.Context) error {
	if !m.enabled {
		return utils.ErrDatabaseDisabled
	}
	if m.getClient() == nil {
		if err := m.connect(); err != nil {
			helpers.Logger.LogInfo(helpers.GetRequestID(context.TODO()), fmt.Sprintf("Error connecting to mongo %v", err.Error()), nil)
			return utils.ErrDatabaseConnection
		}
	}
	return nil
}
IsClientSafe checks whether database is enabled and connected
package mgo
import (
	"context"
	"fmt"
	"strings"
	"sync"
	"time"
	"github.com/spaceuptech/helpers"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
	"github.com/spaceuptech/space-cloud/gateway/config"
	"github.com/spaceuptech/space-cloud/gateway/model"
	"github.com/spaceuptech/space-cloud/gateway/utils"
)
type Mongo struct {
	lock                sync.RWMutex
	queryFetchLimit     *int64
	enabled             bool
	connection          string
	dbName              string
	client              *mongo.Client
	driverConf          config.DriverConfig
	connRetryCloserChan chan struct{}
}
func Init(enabled bool, connection, dbName string, driverConf config.DriverConfig) (mongoStub *Mongo, err error) {
	mongoStub = &Mongo{dbName: dbName, enabled: enabled, connection: connection, client: nil, driverConf: driverConf}
	if mongoStub.enabled {
		err = mongoStub.connect()
		if err != nil {
			return nil, err
		}
	}
	closer := make(chan struct{}, 1)
	mongoStub.connRetryCloserChan = closer
	go func() {
		ticker := time.NewTicker(15 * time.Second)
		for {
			select {
			case <-ticker.C:
				ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
				if !mongoStub.GetConnectionState(ctx) {
					if err := mongoStub.connect(); err != nil {
						_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), fmt.Sprintf("Automatic connection retry failed for mongo db with logical db name (%s)", dbName), err, nil)
					}
				}
				cancel()
			case <-closer:
				close(closer)
				ticker.Stop()
				return
			}
		}
	}()
	return
}
func (m *Mongo) Close() error {
	if m.getClient() != nil {
		m.connRetryCloserChan <- struct{}{}
		if err := m.getClient().Disconnect(context.TODO()); err != nil {
			_ = helpers.Logger.LogError("close", fmt.Sprintf("Unable to close mongo db (%s) connection", m.dbName), err, nil)
		}
		m.setClient(nil)
	}
	return nil
}
func (m *Mongo) IsSame(conn, dbName string, driverConf config.DriverConfig) bool {
	return strings.HasPrefix(m.connection, conn) && dbName == m.dbName && driverConf.MaxConn == m.driverConf.MaxConn && driverConf.MaxIdleTimeout == m.driverConf.MaxIdleTimeout && driverConf.MinConn == m.driverConf.MinConn
}