using MongoDB.Driver;

namespace BukiVedi.Shared.Services.MongoDB
{
    public sealed class MongoDbConnectionProvider
    {
        /// <summary>
        /// Размер очереди запросов в mongoDb
        /// </summary>
        public const int MONGODB_WAIT_QUEUE_LIMIT = 50000;
        /// <summary>
        /// Размер пула подключений к mongoDb
        /// </summary>
        public const int MONGODB_CONNECTION_POOL_SIZE = 5000;
        public static MongoClient CreateClient(string connectionString, int waitQueueLimit = MONGODB_WAIT_QUEUE_LIMIT, int connectionPoolSize = MONGODB_CONNECTION_POOL_SIZE)
        {
            var settings = MongoClientSettings.FromConnectionString(connectionString);
            settings.MaxConnectionPoolSize = connectionPoolSize;
            settings.WaitQueueSize = waitQueueLimit;
            var dbClient = new MongoClient(settings);
            return dbClient;
        }
    }
}
