You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve been reviewing the code for dependency injection of MinioClient in the minio-dotnet SDK, and I noticed some potential confusion in the way the client is being injected based on the ServiceLifetime provided.
var client = minioClientFactory.CreateClient();
client.Config.ServiceProvider = services.BuildServiceProvider();
switch (lifetime)
{
case ServiceLifetime.Singleton:
services.TryAddSingleton(_ => client);
break;
case ServiceLifetime.Scoped:
services.TryAddScoped(_ => client);
break;
case ServiceLifetime.Transient:
services.TryAddTransient(_ => client);
break;
}
The issue is that the client is being created first and then injected as a singleton, scoped, or transient instance based on the lifetime provided. However, it seems like the code is always injecting the same instance of MinioClient, which makes the ServiceLifetime setting effectively irrelevant.
whether it's recommended to use MinioClient as a Singleton or as a Transient/Scoped instance in a typical application?
The text was updated successfully, but these errors were encountered:
I’ve been reviewing the code for dependency injection of MinioClient in the minio-dotnet SDK, and I noticed some potential confusion in the way the client is being injected based on the ServiceLifetime provided.
In the code:
https://github.com/minio/minio-dotnet/blob/master/Minio/ServiceCollectionExtensions.cs
The issue is that the client is being created first and then injected as a singleton, scoped, or transient instance based on the lifetime provided. However, it seems like the code is always injecting the same instance of MinioClient, which makes the ServiceLifetime setting effectively irrelevant.
whether it's recommended to use MinioClient as a Singleton or as a Transient/Scoped instance in a typical application?
The text was updated successfully, but these errors were encountered: