-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Client SDK] Improve ergonomics (#339)
* Simplifies search APIs on `NuGetClient` * Makes it a little easier to create a `CatalogProcessor`
- Loading branch information
1 parent
61c288a
commit 059662e
Showing
5 changed files
with
103 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/BaGet.Protocol/Extensions/NuGetClientFactoryExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using BaGet.Protocol.Catalog; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace BaGet.Protocol | ||
{ | ||
public static class NuGetClientFactoryExtensions | ||
{ | ||
/// <summary> | ||
/// Create a new <see cref="CatalogProcessor"/> to discover and download catalog leafs. | ||
/// Leafs are processed by the <see cref="ICatalogLeafProcessor"/>. | ||
/// </summary> | ||
/// <param name="clientFactory">The factory used to create NuGet clients.</param> | ||
/// <param name="cursor">Cursor to track succesfully processed leafs. Leafs before the cursor are skipped.</param> | ||
/// <param name="leafProcessor">The leaf processor.</param> | ||
/// <param name="options">The options to configure catalog processing.</param> | ||
/// <param name="logger">The logger used for telemetry.</param> | ||
/// <param name="cancellationToken">A token to cancel the task.</param> | ||
/// <returns>The catalog processor.</returns> | ||
public static async Task<CatalogProcessor> CreateCatalogProcessorAsync( | ||
this NuGetClientFactory clientFactory, | ||
ICursor cursor, | ||
ICatalogLeafProcessor leafProcessor, | ||
CatalogProcessorOptions options, | ||
ILogger<CatalogProcessor> logger, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var catalogClient = await clientFactory.CreateCatalogClientAsync(cancellationToken); | ||
|
||
return new CatalogProcessor( | ||
cursor, | ||
catalogClient, | ||
leafProcessor, | ||
options, | ||
logger); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters