init for Reindex

pull/10111/head
johnataylor 10 years ago
parent 9321e7d0e0
commit 61a443a8a8

@ -121,12 +121,14 @@
<Compile Include="CatalogIndexEntry.cs" />
<Compile Include="CatalogIndexReader.cs" />
<Compile Include="CommitCollector.cs" />
<Compile Include="ReindexCatalogCollector.cs" />
<Compile Include="HttpReadCursor.cs" />
<Compile Include="NuspecCollector.cs" />
<Compile Include="RegistrationCatalogCreator.cs" />
<Compile Include="RegistrationCatalogCollector.cs" />
<Compile Include="RegistrationCatalogItem.cs" />
<Compile Include="RegistrationCatalogWriter.cs" />
<Compile Include="ReindexCatalogItem.cs" />
<Compile Include="SortingCollector.cs" />
<Compile Include="SortingGraphCollector.cs" />
<Compile Include="StoreCollector.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<HttpMessageHandler> handlerFunc = null)
: base(index, handlerFunc)
{
_storageFactory = storageFactory;
}
protected override Task<bool> OnProcessBatch(CollectorHttpClient client, IEnumerable<JToken> items, JToken context, DateTime commitTimeStamp)
{
return Task.FromResult(true);
}
}
}

@ -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;
}
}
}

@ -122,6 +122,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ReindexTests.cs" />
<Compile Include="StorageTests.cs" />
<Compile Include="TestCollector.cs" />
<Compile Include="BuilderTests.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<HttpMessageHandler> 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();
}
}
}
Loading…
Cancel
Save