public CatalogProcessor( ICursor cursor, ICatalogClient client, ICatalogLeafProcessor leafProcessor, CatalogProcessorSettings settings, ILogger <CatalogProcessor> logger) { _leafProcessor = leafProcessor ?? throw new ArgumentNullException(nameof(leafProcessor)); _client = client ?? throw new ArgumentNullException(nameof(client)); _cursor = cursor ?? throw new ArgumentNullException(nameof(cursor)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.ServiceIndexUrl == null) { throw new ArgumentException( $"The {nameof(CatalogProcessorSettings.ServiceIndexUrl)} property of the " + $"{nameof(CatalogProcessorSettings)} must not be null.", nameof(settings)); } // Clone the settings to avoid mutability issues. _settings = settings.Clone(); }
/// <summary> /// Create a processor to discover and download catalog leafs. Leafs are processed /// by the <see cref="ICatalogLeafProcessor"/>. /// </summary> /// <param name="cursor">Cursor to track succesfully processed leafs. Leafs before the cursor are skipped.</param> /// <param name="client">The client to interact with the catalog resource.</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> public CatalogProcessor( ICursor cursor, ICatalogResource client, ICatalogLeafProcessor leafProcessor, CatalogProcessorOptions options, ILogger <CatalogProcessor> logger) { _leafProcessor = leafProcessor ?? throw new ArgumentNullException(nameof(leafProcessor)); _client = client ?? throw new ArgumentNullException(nameof(client)); _cursor = cursor ?? throw new ArgumentNullException(nameof(cursor)); _options = options ?? throw new ArgumentNullException(nameof(options)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <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> /// <returns>The catalog processor.</returns> public static CatalogProcessor CreateCatalogProcessor( this NuGetClientFactory clientFactory, ICursor cursor, ICatalogLeafProcessor leafProcessor, CatalogProcessorOptions options, ILogger <CatalogProcessor> logger) { var catalogClient = clientFactory.CreateCatalogClient(); return(new CatalogProcessor( cursor, catalogClient, leafProcessor, options, logger)); }
/// <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)); }