Skip to content

Instantly share code, notes, and snippets.

Joel Verhagen joelverhagen

Block or report user

Report or block joelverhagen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:e31b09b46c44e23958d081f242c260c6
There are many differences between the V2 and V3 APIs. For nuget.org, the main difference is how they are implemented. V2 API is built on top of SQL Server and the V3 API is built on top of Azure blob storage and Lucene for search.
As nuget.org's traffic increased exponentially, it became harder and harder to mean the traffic demands with a SQL database. As you may know, Azure SQL gets very expensive as it scales up and has a maximum size it can reach. Therefore, V3 was implemented on technologies that a small team could easily manage as traffic increased. All of the V3 endpoints used for `nuget.exe restore` are implemented on top of blob storage, which has great availability, is quite cheap, and can be further improved with a CDN in front. I am glossing over details a bit but that's the key difference when V3 split off in the way it did.
V2 is a much more flexible API since it is built on top of OData and therefore supports arbitrary queries beyond the ones nuget.exe performs. For example, you can sort by
@joelverhagen
joelverhagen / ConsoleApp2.csproj
Last active Feb 4, 2019
Generate splot output
View ConsoleApp2.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2;net462</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Net.Http" />
</ItemGroup>
@joelverhagen
joelverhagen / Program.cs
Created Jan 31, 2019
Parallel.For and async
View Program.cs
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting");
@joelverhagen
joelverhagen / Program.cs
Last active Jan 5, 2019
FirstAsync() works, Take(1).ToListAsync() times out, Take(1).FirstAsync() throws
View Program.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace ConsoleApp1
{
@joelverhagen
joelverhagen / Program.cs
Created May 11, 2018
Simulate problems related to using timestamp cursors against a SQL table
View Program.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@joelverhagen
joelverhagen / Program.cs
Created Apr 29, 2018
Two TorSharpProxy instances running in parallel
View Program.cs
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Knapcode.TorSharp;
namespace ConsoleApp1
{
class Program
@joelverhagen
joelverhagen / Program.cs
Created Feb 13, 2018
NuGet API, get download count per version
View Program.cs
// All you need is the NuGet.Protocol package from NuGet.org.
using System;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
namespace ConsoleApp1
{
@joelverhagen
joelverhagen / Program.cs
Created Dec 11, 2017
Round trip a certificate through a UTF-8 string
View Program.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
@joelverhagen
joelverhagen / .gitattributes
Last active May 2, 2018
Generate a test CA for NuGet package signing, props to @dtivel for initial implementation
View .gitattributes
*.conf text eol=lf
*.config text eol=lf
*.sh text eol=lf
@joelverhagen
joelverhagen / Routes.cs
Created Nov 28, 2017
Example of custom IPackageService in NuGet.Server 2.8.2
View Routes.cs
using System.Data.Services;
using System.ServiceModel.Activation;
using System.Web;
using System.Web.Routing;
using NuGet.Server;
using NuGet.Server.DataServices;
using NuGet.Server.Infrastructure;
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(WebApplication1.NuGetRoutes), "Start")]
You can’t perform that action at this time.