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(); }
private static async Task MainAsync() { using (var loggerFactory = new LoggerFactory().AddConsole(LogLevel.Warning)) using (var httpClient = new HttpClient()) { var simpleHttpClient = new SimpleHttpClient(httpClient, loggerFactory.CreateLogger <SimpleHttpClient>()); var fileCursor = new FileCursor("cursor.json", loggerFactory.CreateLogger <FileCursor>()); var catalogClient = new CatalogClient(simpleHttpClient, loggerFactory.CreateLogger <CatalogClient>()); var leafProcessor = new LoggerCatalogLeafProcessor(loggerFactory.CreateLogger <LoggerCatalogLeafProcessor>()); var settings = new CatalogProcessorSettings { DefaultMinCommitTimestamp = DateTimeOffset.UtcNow.AddHours(-1), ExcludeRedundantLeaves = false, }; var catalogProcessor = new CatalogProcessor( fileCursor, catalogClient, leafProcessor, settings, loggerFactory.CreateLogger <CatalogProcessor>()); bool success; do { success = await catalogProcessor.ProcessAsync(); if (!success) { Console.WriteLine("Processing the catalog leafs failed. Retrying."); } }while (!success); } }
public void CopiesAllProperties() { // Arrange var expected = new CatalogProcessorSettings { ServiceIndexUrl = "https://example/v3/index.json", DefaultMinCommitTimestamp = new DateTimeOffset(2017, 11, 8, 13, 50, 44, TimeSpan.Zero), MinCommitTimestamp = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero), MaxCommitTimestamp = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero), ExcludeRedundantLeaves = true, }; // Act var actual = expected.Clone(); // Assert actual.Should().BeEquivalentTo(expected); }
public void HasUnchangingDefaults() { // Arrange var expected = new CatalogProcessorSettings { ServiceIndexUrl = "https://api.nuget.org/v3/index.json", DefaultMinCommitTimestamp = null, MinCommitTimestamp = DateTimeOffset.MinValue, MaxCommitTimestamp = DateTimeOffset.MaxValue, ExcludeRedundantLeaves = true, }; // Act var actual = new CatalogProcessorSettings(); // Assert actual.Should().BeEquivalentTo(expected); }