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

feat(http client factory): expose Count #89

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Fluently Http Changelog

[_vNext_](https://github.com/sketch7/FluentlyHttpClient/compare/3.8.1...3.9.0) (2020-X-X)
[_vNext_](https://github.com/sketch7/FluentlyHttpClient/compare/4.0.1...4.1.0) (2024-X-X)

## [4.0.1](https://github.com/sketch7/FluentlyHttpClient/compare/4.0.0...4.0.1) (2024-08-28)

### Features

- **http client factory:** expose `Count` to know how many clients are registered

## [4.0.0](https://github.com/sketch7/FluentlyHttpClient/compare/3.9.6...4.0.0) (2024-07-24)

Expand Down
11 changes: 9 additions & 2 deletions src/FluentlyHttpClient/FluentHttpClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FluentlyHttpClient;
namespace FluentlyHttpClient;

/// <summary>
/// HTTP client factory which contains registered HTTP clients and able to get existing or creating new ones.
Expand Down Expand Up @@ -54,6 +54,11 @@ public interface IFluentHttpClientFactory
/// <param name="identifier">Identifier to check.</param>
/// <returns>Returns true when already exists.</returns>
bool Has(string identifier);

/// <summary>
/// Get the amount of clients registered.
/// </summary>
int Count { get; }
}

/// <summary>
Expand All @@ -62,9 +67,11 @@ public interface IFluentHttpClientFactory
public class FluentHttpClientFactory : IFluentHttpClientFactory
{
private readonly IServiceProvider _serviceProvider;
private readonly Dictionary<string, IFluentHttpClient> _clientsMap = new();
private readonly Dictionary<string, IFluentHttpClient> _clientsMap = [];
private Action<FluentHttpClientBuilder>? _configure;

public int Count => _clientsMap.Count;

/// <summary>
/// Initializes a new instance of <see cref="FluentHttpClientFactory"/>.
/// </summary>
Expand Down
Loading