Skip to content
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
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
next-version: 2.0.1
next-version: 2.1.0
tag-prefix: '[vV]'
mode: ContinuousDeployment
branches:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <img src="https://github.com/CodeShayk/ApiAggregator/blob/master/Images/ninja-icon-16.png" alt="ninja" style="width:30px;"/> ApiAggregator v2.0.1
# <img src="https://github.com/CodeShayk/ApiAggregator/blob/master/Images/ninja-icon-16.png" alt="ninja" style="width:30px;"/> ApiAggregator v2.1.0
[![NuGet version](https://badge.fury.io/nu/ApiAggregator.svg)](https://badge.fury.io/nu/ApiAggregator) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CodeShayk/ApiAggregator/blob/master/LICENSE.md)
[![Master-Build](https://github.com/CodeShayk/ApiAggregator/actions/workflows/Master-Build.yml/badge.svg)](https://github.com/CodeShayk/ApiAggregator/actions/workflows/Master-Build.yml)
[![GitHub Release](https://img.shields.io/github/v/release/CodeShayk/ApiAggregator?logo=github&sort=semver)](https://github.com/CodeShayk/ApiAggregator/releases/latest)
Expand All @@ -17,6 +17,8 @@ ApiAggregator is useful in many use cases. Few to list are:
- For on demand retrieval of data using different subsets of configured apis to fetch varied datasets per request.
- and Many more.

Please see [Wiki](https://github.com/CodeShayk/ApiAggregator/wiki) for more use cases.

## Getting Started?
### i. Installation
Install the latest version of ApiAggregator nuget package with command below.
Expand Down Expand Up @@ -45,6 +47,7 @@ We welcome contributions! Please see our Contributing Guide for details.
The main branch is now on .NET 9.0. The following previous versions are available:
| Version | Release Notes |
| -------- | --------|
| [`v2.1.0`](https://github.com/CodeShayk/ApiAggregator/tree/v2.1.0) | [Notes](https://github.com/CodeShayk/ApiAggregator/releases/tag/v2.1.0) |
| [`v2.0.0`](https://github.com/CodeShayk/ApiAggregator/tree/v2.0.0) | [Notes](https://github.com/CodeShayk/ApiAggregator/releases/tag/v2.0.0) |
| [`v1.0.0`](https://github.com/CodeShayk/ApiAggregator/tree/v1.0.0) | [Notes](https://github.com/CodeShayk/ApiAggregator/releases/tag/v1.0.0) |

Expand Down
10 changes: 7 additions & 3 deletions src/ApiAggregator/ApiAggregator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
<PackageProjectUrl>https://github.com/CodeShayk/ApiAggregator/wiki</PackageProjectUrl>
<RepositoryUrl>https://github.com/CodeShayk/ApiAggregator</RepositoryUrl>
<PackageReleaseNotes>
v2.0.1 - Targets .Net9.0, net5.0, net6.0, net8.0, .Net Standard 2.0, and .Net Framework 4.6.2. <br />
- Includes core functionality for aggregating apis.</PackageReleaseNotes>
<Version>2.0.1</Version>
v2.1.0 - Targets .Net9.0, net5.0, net6.0, net8.0, .Net Standard 2.0, and .Net Framework 4.6.2. <br />
- Critical fix: Eliminated async/await blocking operations that could cause deadlocks
- Code quality: Fixed syntax consistency issues and improved maintainability
- Performance: Better handling of concurrent API requests and improved thread pool utilization
- Maintains 100% backward compatibility
</PackageReleaseNotes>
<Version>2.1.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
15 changes: 12 additions & 3 deletions src/ApiAggregator/Impl/ApiEngine.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -33,13 +34,21 @@ public IEnumerable<IApiResult> Execute(IEnumerable<IWebApi> apis)
.Select(q => q.Run(httpClientFactory, logger))
.ToArray();

Task.WhenAll(tasks);
try
{
Task.WaitAll(tasks);
}
catch (AggregateException ex)
{
// Re-throw the actual exception that occurred in the tasks
throw ex.Flatten();
}

var results = new List<IApiResult>();

foreach (var task in tasks)
for (int i = 0; i < tasks.Length; i++)
{
var result = task.Result;
var result = tasks[i].Result;
if (result != null)
results.Add(result);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ApiAggregator/ServicesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public static IServiceCollection UseApiAggregator(this IServiceCollection servic
services.AddTransient(typeof(IContractBuilder<>), typeof(ContractBuilder<>));
services.AddTransient(typeof(IApiAggregator<>), typeof(ApiAggregator<>));

services.AddTransient<IApiExecutor, ApiExecutor>();
services.AddTransient<IApiNameMatcher, StringContainsMatcher>();
services.AddTransient<IApiEngine, ApiEngine>();
services.AddTransient(typeof(IApiExecutor), typeof(ApiExecutor));
services.AddTransient(typeof(IApiNameMatcher), typeof(StringContainsMatcher));
services.AddTransient(typeof(IApiEngine), typeof(ApiEngine));

return services;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ApiAggregator/WebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/// </summary>
/// <returns></returns>
protected virtual IEnumerable<string> GetResponseHeaders()
{ return Enumerable.Empty<string>(); ; }
{ return Enumerable.Empty<string>(); }

/// <summary>
/// Implement to construct the api endpoint.
Expand All @@ -79,7 +79,7 @@
/// </summary>
/// <param name="context">Request context.</param>
/// <param name="parentApiResult">api result from parent api (when configured as nested api). Can be null.</param>
void IWebApi.ResolveApiParameter(IRequestContext context, IApiResult parentApiResult = null)

Check warning on line 82 in src/ApiAggregator/WebApi.cs

View workflow job for this annotation

GitHub Actions / Build-Test

The default value specified for parameter 'parentApiResult' will have no effect because it applies to a member that is used in contexts that do not allow optional arguments
{
Url = GetUrl(context, parentApiResult);
isContextResolved = true;
Expand Down Expand Up @@ -123,7 +123,7 @@

result = await client.GetAsync(Url);

var raw = result.Content.ReadAsStringAsync().Result;
var raw = await result.Content.ReadAsStringAsync();

if (!string.IsNullOrWhiteSpace(raw))
logger?.LogInformation($"Result.Content of executing web api: {Url} is {raw}");
Expand Down
Loading