Skip to content

Commit

Permalink
Clean up and mark parameterized MinioClient constructor obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
ebozduman committed Jun 8, 2022
1 parent 0ce9bef commit a13707e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 74 deletions.
18 changes: 8 additions & 10 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,14 @@ MinioClient minioClient = new MinioClient()
### AWS S3

```cs
// 1. public MinioClient(String endpoint, String accessKey, String secretKey)
MinioClient s3Client = new MinioClient("s3.amazonaws.com",
accessKey:"YOUR-ACCESSKEYID",
secretKey:"YOUR-SECRETACCESSKEY");
// 2. Using Builder with public MinioClient(), Endpoint, Credentials & Secure connection
MinioClient minioClient = new MinioClient()
.WithEndpoint("s3.amazonaws.com")
.WithCredentials("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY")
.WithSSL()
.Build()
// 1. Using Builder with public MinioClient(), Endpoint, Credentials, Secure connection & proxy
MinioClient s3Client = new MinioClient("s3.amazonaws.com");
.WithEndpoint("s3.amazonaws.com")
.WithCredentials("YOUR-AWS-ACCESSKEYID", "YOUR-AWS-SECRETACCESSKEY")
.WithSSL()
.WithProxy(proxy)
.Build();

```

## 2. Bucket operations
Expand Down
55 changes: 0 additions & 55 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5714,60 +5714,5 @@ internal static async Task BucketLifecycleAsync_Test2(MinioClient minio)
}
}

internal static async Task SocketLeakage_Test(MinioClient minio)
{
var startTime = DateTime.Now;
var bucketName = GetRandomName(15);
var args = new Dictionary<string, string>
{
{ "bucketName", bucketName }
};

var mbArgs = new MakeBucketArgs()
.WithBucket(bucketName);
var beArgs = new BucketExistsArgs()
.WithBucket(bucketName);
var rbArgs = new RemoveBucketArgs()
.WithBucket(bucketName);

try
{
var found = await minio.BucketExistsAsync(beArgs);
if (!found) await minio.MakeBucketAsync(mbArgs);

await Task.WhenAll(Enumerable.Range(0, 100_000).Select(async index =>
{
await minio.BucketExistsAsync(beArgs);
})).ConfigureAwait(false);

new MintLogger(nameof(SocketLeakage_Test), bucketExistsSignature,
"Tests HttpClient library's socket leakage issue",
TestStatus.PASS,
DateTime.Now - startTime, args: args).Log();
}
catch (NotImplementedException)
{
new MintLogger(nameof(SocketLeakage_Test), bucketExistsSignature,
"Tests HttpClient library's socket leakage issue",
TestStatus.NA,
DateTime.Now - startTime,
"Functionality that is not implemented", "", args: args).Log();
}
catch (Exception ex)
{
new MintLogger(nameof(SocketLeakage_Test), bucketExistsSignature,
"Tests HttpClient library's socket leakage issue",
TestStatus.FAIL,
DateTime.Now - startTime,
ex.Message, ex.ToString(), args: args).Log();
throw;
}
finally
{
var found = await minio.BucketExistsAsync(beArgs);
if (!found) await minio.RemoveBucketAsync(rbArgs);
}
}

#endregion
}
6 changes: 2 additions & 4 deletions Minio.Functional.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ public static void Main(string[] args)
.WithHttpClient(httpClient)
.Build();
else
minioClient = new MinioClient(httpClient)
minioClient = new MinioClient()
.WithCredentials(accessKey, secretKey)
.WithEndpoint(endPoint)
.WithHttpClient(httpClient)
.Build();

// Assign parameters before starting the test
Expand Down Expand Up @@ -199,9 +200,6 @@ public static void Main(string[] args)
FunctionalTest.BucketLifecycleAsync_Test1(minioClient).Wait();
FunctionalTest.BucketLifecycleAsync_Test2(minioClient).Wait();

// Test Socket/Memory Leak
FunctionalTest.SocketLeakage_Test(minioClient).Wait();

// Test encryption
if (enableHttps == "1")
{
Expand Down
6 changes: 1 addition & 5 deletions Minio/MinioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public MinioClient()
/// Creates and returns an MinIO Client with custom HTTP Client
/// </summary>
/// <returns>Client with no arguments to be used with other builder methods</returns>
[Obsolete("Use MinioClient() and Builder method .WithHttpClient(httpClient)")]
public MinioClient(HttpClient httpClient)
{
Region = "";
Expand Down Expand Up @@ -441,11 +442,6 @@ public MinioClient WithRetryPolicy(RetryPolicyHandlingDelegate retryPolicyHandle
/// <returns></returns>
public MinioClient WithHttpClient(HttpClient httpClient)
{
if (HTTPClient != null)
// It has been already set. We ignore
// An alternative is an ERROR or a WARNING
// Please advise during code review
return this;
if (httpClient != null) HTTPClient = httpClient;
return this;
}
Expand Down

0 comments on commit a13707e

Please sign in to comment.