/// <summary> /// Creates the elfie indexes. /// </summary> async Task CreateIndex(Catalog2ElfieOptions options, CancellationToken cancellationToken) { // The NuGet service catalog root. Uri nugetServicesUri = new Uri(options.Source); // The list of NuGet service endpoints. NugetServiceEndpoints nugetServiceUrls = new NugetServiceEndpoints(new Uri(options.Source)); // The storage object responsible for loading and saving files from storage. Storage storage = options.StorageFactory.Create(); Uri downloadCountsUri = new Uri(options.DownloadSource); ElfieFromCatalogCollector collector = new ElfieFromCatalogCollector(options.IndexerVersion, options.MergerVersion, nugetServiceUrls, downloadCountsUri, options.DownloadPercentage, storage, options.MaxThreads, options.TempPath); int reties = 3; for (int attempt = 0; attempt < reties; attempt++) { bool success = await collector.Run(cancellationToken); // The collector returns true if it successfully created the indexes, // returns false if it couldn't create the indexes, but the error is transient, // throws an exception if it encounters an unrecoverable error. if (success) { break; } else { // Wait for a few seconds before retrying. int delay = (int)Math.Pow(15, reties); Thread.Sleep(delay * 1000); } } }
public ElfieFromCatalogCollector(Version indexerVersion, Version mergerVersion, NugetServiceEndpoints nugetServiceUrls, Uri downloadCountsUri, double downloadPercentage, Storage storage, int maxThreads, string tempPath) { this._storage = storage; this._maxThreads = maxThreads; this._tempPath = Path.GetFullPath(tempPath); this._indexerVersion = indexerVersion; this._mergerVersion = mergerVersion; this._nugetServiceUrls = nugetServiceUrls; this._downloadCountsUri = downloadCountsUri; this._downloadPercentage = downloadPercentage; }