Skip to content

Commit

Permalink
Refactor upstream clients (loic-sharma#709)
Browse files Browse the repository at this point in the history
This pushes logic from the `MirrorService` down into the `V2UpstreamClient` and `V3UpstreamClient` and adds tests on the `V3UpstreamClient`. This will make it easier to refactor the `MirrorService`, which will make it easier to implement the legacy V2 APIs in BaGet.

Split from loic-sharma#699
  • Loading branch information
loic-sharma authored Dec 12, 2021
1 parent fb1f8e4 commit dec4013
Show file tree
Hide file tree
Showing 12 changed files with 677 additions and 372 deletions.
10 changes: 5 additions & 5 deletions src/BaGet.Core/Extensions/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ private static void AddBaGetServices(this IServiceCollection services)
services.TryAddTransient<DatabaseSearchService>();
services.TryAddTransient<FileStorageService>();
services.TryAddTransient<MirrorService>();
services.TryAddTransient<MirrorV2Client>();
services.TryAddTransient<MirrorV3Client>();
services.TryAddTransient<V2UpstreamClient>();
services.TryAddTransient<V3UpstreamClient>();
services.TryAddTransient<DisabledMirrorService>();
services.TryAddSingleton<NullStorageService>();
services.TryAddTransient<PackageDatabase>();
Expand Down Expand Up @@ -203,12 +203,12 @@ private static IMirrorService IMirrorServiceFactory(IServiceProvider provider)
return (IMirrorService)provider.GetRequiredService(service);
}

private static IMirrorClient IMirrorClientFactory(IServiceProvider provider)
private static IUpstreamClient IMirrorClientFactory(IServiceProvider provider)
{
var options = provider.GetRequiredService<IOptionsSnapshot<MirrorOptions>>();
var service = options.Value.Legacy ? typeof(MirrorV2Client) : typeof(MirrorV3Client);
var service = options.Value.Legacy ? typeof(V2UpstreamClient) : typeof(V3UpstreamClient);

return (IMirrorClient)provider.GetRequiredService(service);
return (IUpstreamClient)provider.GetRequiredService(service);
}
}
}
155 changes: 0 additions & 155 deletions src/BaGet.Core/Mirror/Clients/MirrorV2Client.cs

This file was deleted.

63 changes: 0 additions & 63 deletions src/BaGet.Core/Mirror/Clients/MirrorV3Client.cs

This file was deleted.

Loading

0 comments on commit dec4013

Please sign in to comment.