-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Currently EntityContext<TEntity> and MongoRepositoryHealthCheck create MongoClient instances internally. In v10.2.0, a static ConcurrentDictionary<string, MongoClient> cache was added to avoid creating new clients per request, which solves the immediate connection pool waste problem.
However, the proper solution for v11 is to let the DI container manage MongoClient lifetime as a Singleton, allowing consumers to configure client settings (timeouts, SSL, etc.) in one place.
Proposed changes
- Register
MongoClientas a Singleton in DI (keyed by connection string or named options) - Inject
MongoClientintoEntityContext<TEntity>instead of creating it internally - Inject
MongoClientintoMongoRepositoryHealthCheck - Remove the static
ConcurrentDictionarycaches - This is a breaking change (constructor signatures change)
Target version
v11.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request