Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitAuto: [FEATURE] Refactor to use HttpClientFactory for HTTP client management #416

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Src/VTEX.Health/VtexHealthClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@
/// Initializes a new instance of the <see cref="VtexHealthClient" /> class.
/// </summary>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="httpClientFactory">The HTTP client factory.</param>
/// <exception cref="System.ArgumentNullException">loggerFactory</exception>
/// <exception cref="System.ArgumentNullException">httpClient</exception>
public VtexHealthClient(ILoggerFactory loggerFactory, HttpClient httpClient)
public VtexHealthClient(ILoggerFactory loggerFactory, IHttpClientFactory httpClientFactory)
{
if (loggerFactory == null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}

_logger = loggerFactory.CreateLogger<VtexHealthClient>();
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
}
_httpClient = httpClientFactory?.CreateClient() ?? throw new ArgumentNullException(nameof(httpClientFactory));
httpClientFactory?.CreateClient() ?? throw new ArgumentNullException(nameof(httpClientFactory));

#endregion

#region Implementation of IVtexHealthClient

/// <inheritdoc />
public async Task<IEnumerable<PlatformStatus>> GetPlatformStatuesAsync(

Check failure on line 66 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

The modifier 'public' is not valid for this item

Check failure on line 66 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

The modifier 'public' is not valid for this item

Check failure on line 66 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

The modifier 'public' is not valid for this item

Check failure on line 66 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

The modifier 'public' is not valid for this item

Check failure on line 66 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

The modifier 'public' is not valid for this item
CancellationToken cancellationToken
)
{
Expand All @@ -78,4 +78,4 @@

#endregion
}
}

Check failure on line 81 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected

Check failure on line 81 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected

Check failure on line 81 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected

Check failure on line 81 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected

Check failure on line 81 in Src/VTEX.Health/VtexHealthClient.cs

View workflow job for this annotation

GitHub Actions / Deep Source Coverage report

} expected
5 changes: 2 additions & 3 deletions Src/VTEX/VTEXWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@

var cookieContainer = new CookieContainer();

using var handler = new HttpClientHandler { CookieContainer = cookieContainer };

using var client = new HttpClient(handler);
var handler = new HttpClientHandler { CookieContainer = cookieContainer };

Check notice on line 165 in Src/VTEX/VTEXWrapper.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Src/VTEX/VTEXWrapper.cs#L165

Remove the unused local variable 'handler'.
var client = _httpClientFactory.CreateClient();

ConfigureClient(client, requiresAuthentication);

Expand Down
Loading