mongo stability debug + zoom

This commit is contained in:
mr
2024-08-02 15:06:40 +02:00
parent fa52c71e93
commit efa73d8a45
3 changed files with 6 additions and 1 deletions

View File

@@ -92,6 +92,8 @@ func (m *MongoDB) createClient(MongoURL string) error {
func (m *MongoDB) prepareDB(list_collection []string, config MongoConf) {
var err error
mngoDB = mngoClient.Database(config.GetDatabase())
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
existingCollections, err = mngoDB.ListCollectionNames(MngoCtx, bson.D{})
if err != nil {
m.Logger.Fatal().Msg("Error contacting MongoDB\n" + err.Error())
@@ -116,6 +118,8 @@ func (m *MongoDB) prepareDB(list_collection []string, config MongoConf) {
// Creates the collection with index specified in mongo/mongo_collections
// or use the basic collection creation function
func (m *MongoDB) createCollection(collection_name string, new_collection *mongo.Collection) {
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
var err error
CollectionMap[collection_name] = new_collection
_, exists := IndexesMap[collection_name]