diff --git a/Streetwriters.Data/DbContexts/MongoDbContext.cs b/Streetwriters.Data/DbContexts/MongoDbContext.cs
index 3627d20..55bc3f5 100644
--- a/Streetwriters.Data/DbContexts/MongoDbContext.cs
+++ b/Streetwriters.Data/DbContexts/MongoDbContext.cs
@@ -17,14 +17,14 @@ You should have received a copy of the Affero GNU General Public License
along with this program. If not, see .
*/
-using Microsoft.Extensions.Configuration;
-using MongoDB.Driver;
-using Streetwriters.Data.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
+using MongoDB.Driver;
+using Streetwriters.Data.Interfaces;
namespace Streetwriters.Data.DbContexts
{
@@ -35,15 +35,22 @@ namespace Streetwriters.Data.DbContexts
var settings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString);
settings.MaxConnectionPoolSize = 500;
settings.MinConnectionPoolSize = 0;
+ settings.HeartbeatInterval = TimeSpan.FromSeconds(60);
return new MongoClient(settings);
}
- public static IMongoCollection GetMongoCollection(IMongoClient client, string databaseName, string collectionName)
+ public static IMongoCollection GetMongoCollection(
+ IMongoClient client,
+ string databaseName,
+ string collectionName
+ )
{
- return client.GetDatabase(databaseName).GetCollection(collectionName, new MongoCollectionSettings()
- {
- AssignIdOnInsert = true,
- });
+ return client
+ .GetDatabase(databaseName)
+ .GetCollection(
+ collectionName,
+ new MongoCollectionSettings() { AssignIdOnInsert = true }
+ );
}
private readonly List> _commands = [];
@@ -59,13 +66,14 @@ namespace Streetwriters.Data.DbContexts
#if (DEBUG || STAGING)
await Parallel.ForEachAsync(_commands, async (c, ct) => await c(session, ct));
#else
- await session.WithTransactionAsync(async (handle, token) =>
- {
- await Task.WhenAll(_commands.Select(c => c(handle, token)));
- return true;
- });
+ await session.WithTransactionAsync(
+ async (handle, token) =>
+ {
+ await Task.WhenAll(_commands.Select(c => c(handle, token)));
+ return true;
+ }
+ );
#endif
-
}
return count;
}
@@ -87,4 +95,4 @@ namespace Streetwriters.Data.DbContexts
GC.SuppressFinalize(this);
}
}
-}
\ No newline at end of file
+}