26.37. Class MongoCollectionProvider<TData, TModelMapping>
Namespace: ArmoniK.Core.Adapters.MongoDB.Common
Assembly: ArmoniK.Core.Adapters.MongoDB.dll
Provides a MongoDB collection for data operations, implementing initialization and async initialization.
[PublicAPI]
public class MongoCollectionProvider<TData, TModelMapping> : IInitializable, IHealthCheckProvider, IAsyncInitialization<IMongoCollection<TData>> where TModelMapping : IMongoDataModelMapping<TData>, new()
26.37.1. Type Parameters
TData
The type of data stored in the MongoDB collection.
TModelMapping
The type of the model mapping that defines the MongoDB collection mapping.
26.37.2. Inheritance
26.37.3. Implements
IInitializable, IHealthCheckProvider, IAsyncInitialization<IMongoCollection<TData>>
26.37.4. Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
26.37.5. Remarks
This class is responsible for providing access to a MongoDB collection and ensuring it is properly initialized.
26.37.6. Constructors
26.37.6.1. MongoCollectionProvider(MongoDB, InitDatabase, SessionProvider, IMongoDatabase, ILogger<IMongoCollection<TData>>, CancellationToken)
Initializes a new instance of the
public MongoCollectionProvider(MongoDB options, InitDatabase initDatabase, SessionProvider sessionProvider, IMongoDatabase mongoDatabase, ILogger<IMongoCollection<TData>> logger, CancellationToken cancellationToken = default)
26.37.6.1.1. Parameters
options MongoDB
The MongoDB options used for configuration, including data retention settings.
initDatabase InitDatabase
The init data used to populate the database.
sessionProvider SessionProvider
The session provider used to manage MongoDB sessions.
mongoDatabase IMongoDatabase
The MongoDB database instance to which the collection belongs.
logger ILogger<IMongoCollection<TData>>
The logger instance used for logging purposes.
cancellationToken CancellationToken
A cancellation token to observe while waiting for the initialization to complete (optional).
26.37.6.1.2. Exceptions
Thrown when the data retention option is not defined (i.e., set to zero).
26.37.7. Properties
26.37.7.1. Initialization
The result of the asynchronous initialization of this instance.
public Task<IMongoCollection<TData>> Initialization { get; }
26.37.7.1.1. Property Value
Task<IMongoCollection<TData>>
26.37.8. Methods
26.37.8.1. Check(HealthCheckTag)
Checks the status of a class for the given health check type.
public Task<HealthCheckResult> Check(HealthCheckTag tag)
26.37.8.1.1. Parameters
tag HealthCheckTag
Health check for which the class has to answer.
26.37.8.1.2. Returns
The result of the check containing the status of the class for the health check type.
26.37.8.2. Get()
Retrieves the MongoDB collection for data operations.
public IMongoCollection<TData> Get()
26.37.8.2.1. Returns
IMongoCollection<TData>
The MongoDB collection of type
26.37.8.2.2. Exceptions
Thrown when the MongoDB collection has not been initialized.
Ensure that the
26.37.8.3. Init(CancellationToken)
Executes an initialization process for the class
public Task Init(CancellationToken cancellationToken)
26.37.8.3.1. Parameters
cancellationToken CancellationToken
Token used to cancel the execution of the method
26.37.8.3.2. Returns
Task representing the asynchronous execution of the method