diff --git a/src/Catalog/NuGet.Services.Metadata.Catalog.csproj b/src/Catalog/NuGet.Services.Metadata.Catalog.csproj index bd9fc8823..2c1e415a0 100644 --- a/src/Catalog/NuGet.Services.Metadata.Catalog.csproj +++ b/src/Catalog/NuGet.Services.Metadata.Catalog.csproj @@ -121,12 +121,14 @@ + + diff --git a/src/Catalog/ReindexCatalogCollector.cs b/src/Catalog/ReindexCatalogCollector.cs new file mode 100644 index 000000000..032a6ddb1 --- /dev/null +++ b/src/Catalog/ReindexCatalogCollector.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json.Linq; +using NuGet.Services.Metadata.Catalog.Persistence; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; + +namespace NuGet.Services.Metadata.Catalog +{ + public class ReindexCatalogCollector : CommitCollector + { + StorageFactory _storageFactory; + + public ReindexCatalogCollector(Uri index, StorageFactory storageFactory, Func handlerFunc = null) + : base(index, handlerFunc) + { + _storageFactory = storageFactory; + } + + protected override Task OnProcessBatch(CollectorHttpClient client, IEnumerable items, JToken context, DateTime commitTimeStamp) + { + + return Task.FromResult(true); + } + } +} diff --git a/src/Catalog/ReindexCatalogItem.cs b/src/Catalog/ReindexCatalogItem.cs new file mode 100644 index 000000000..4a9b84f80 --- /dev/null +++ b/src/Catalog/ReindexCatalogItem.cs @@ -0,0 +1,26 @@ +using System; + +namespace NuGet.Services.Metadata.Catalog +{ + public class ReindexCatalogItem : CatalogItem + { + Uri _itemAddress; + Uri _itemType; + + public ReindexCatalogItem(Uri itemAddress, Uri itemType) + { + _itemAddress = itemAddress; + _itemType = itemType; + } + + public override Uri GetItemType() + { + return _itemType; + } + + public override Uri GetItemAddress() + { + return _itemAddress; + } + } +} diff --git a/tests/CatalogTests/CatalogTests.csproj b/tests/CatalogTests/CatalogTests.csproj index 102a4913a..bd716d7e1 100644 --- a/tests/CatalogTests/CatalogTests.csproj +++ b/tests/CatalogTests/CatalogTests.csproj @@ -122,6 +122,7 @@ + diff --git a/tests/CatalogTests/ReindexTests.cs b/tests/CatalogTests/ReindexTests.cs new file mode 100644 index 000000000..01537d74c --- /dev/null +++ b/tests/CatalogTests/ReindexTests.cs @@ -0,0 +1,40 @@ +using NuGet.Services.Metadata.Catalog; +using NuGet.Services.Metadata.Catalog.Persistence; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace CatalogTests +{ + public class ReindexTests + { + public static async Task Test0Async() + { + Func handlerFunc = () => + { + return new FileSystemEmulatorHandler + { + BaseAddress = new Uri("http://localhost:8000"), + RootFolder = @"c:\data\site", + InnerHandler = new HttpClientHandler() + }; + }; + + StorageFactory storageFactory = new FileStorageFactory(new Uri("http://localhost:8000/nuspec/"), @"c:\data\site\nuspec"); + + CommitCollector collector = new ReindexCatalogCollector(new Uri("http://localhost:8000/full/index.json"), storageFactory, handlerFunc); + + await collector.Run(); + + Console.WriteLine("http requests: {0}", collector.RequestCount); + } + + public static void Test0() + { + Test0Async().Wait(); + } + } +}