Skip to content

Commit fe567d4

Browse files
authored
Make the controller and repository stack async (#28)
1 parent 8a9a1cd commit fe567d4

12 files changed

Lines changed: 611 additions & 403 deletions

File tree

src/NuGet.Server.Core/Infrastructure/IServerPackageRepository.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5-
using System.Linq;
5+
using System.Threading;
6+
using System.Threading.Tasks;
67

78
namespace NuGet.Server.Core.Infrastructure
89
{
910
public interface IServerPackageRepository
1011
{
1112
string Source { get; }
1213

13-
void AddPackage(IPackage package);
14+
Task AddPackageAsync(IPackage package, CancellationToken token);
1415

15-
IQueryable<IServerPackage> GetPackages();
16+
Task<IEnumerable<IServerPackage>> GetPackagesAsync(CancellationToken token);
1617

17-
IQueryable<IServerPackage> Search(
18+
Task<IEnumerable<IServerPackage>> SearchAsync(
1819
string searchTerm,
1920
IEnumerable<string> targetFrameworks,
20-
bool allowPrereleaseVersions);
21+
bool allowPrereleaseVersions,
22+
CancellationToken token);
2123

22-
void ClearCache();
24+
Task ClearCacheAsync(CancellationToken token);
2325

24-
void RemovePackage(string packageId, SemanticVersion version);
26+
Task RemovePackageAsync(string packageId, SemanticVersion version, CancellationToken token);
2527
}
2628
}

src/NuGet.Server.Core/Infrastructure/IServerPackageStore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5+
using System.Threading;
6+
using System.Threading.Tasks;
57

68
namespace NuGet.Server.Core.Infrastructure
79
{
@@ -16,7 +18,7 @@ public interface IServerPackageStore
1618

1719
bool Exists(string id, SemanticVersion version);
1820

19-
HashSet<ServerPackage> GetAll(bool enableDelisting);
21+
Task<HashSet<ServerPackage>> GetAllAsync(bool enableDelisting, CancellationToken token);
2022

2123
void Remove(string id, SemanticVersion version, bool enableDelisting);
2224
}

src/NuGet.Server.Core/Infrastructure/ServerPackageExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static bool IsReleaseVersion(this IServerPackage package)
1414
return string.IsNullOrEmpty(package.Version.SpecialVersion);
1515
}
1616

17-
public static IQueryable<T> FilterByPrerelease<T>(this IQueryable<T> packages, bool allowPrerelease)
17+
public static IEnumerable<T> FilterByPrerelease<T>(this IEnumerable<T> packages, bool allowPrerelease)
1818
where T : IServerPackage
1919
{
2020
if (packages == null)
@@ -30,7 +30,7 @@ public static IQueryable<T> FilterByPrerelease<T>(this IQueryable<T> packages, b
3030
return packages;
3131
}
3232

33-
public static IQueryable<T> Find<T>(this IQueryable<T> packages, string searchText)
33+
public static IEnumerable<T> Find<T>(this IEnumerable<T> packages, string searchText)
3434
where T : IServerPackage
3535
{
3636
var terms = searchText

0 commit comments

Comments
 (0)