mongo and or

This commit is contained in:
mr 2024-08-02 16:39:10 +02:00
parent 89f14d99b8
commit 51541010e2

View File

@ -68,8 +68,10 @@ func (m *MongoDB) createClient(MongoURL string) error {
isConnected = false
return errors.New("Mongodb connect " + MongoURL + ":" + err.Error())
}
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err = mngoClient.Ping(MngoCtx, nil); err != nil || mngoClient == nil {
if err = mngoClient.Ping(MngoCtx, nil); err != nil {
mngoClient = nil
isConnected = false
return errors.New("Mongodb ping " + MongoURL + ":" + err.Error())