Skip to content

Commit dec4013

Browse files
authored
Refactor upstream clients (loic-sharma#709)
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
1 parent fb1f8e4 commit dec4013

12 files changed

+677
-372
lines changed

src/BaGet.Core/Extensions/DependencyInjectionExtensions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ private static void AddBaGetServices(this IServiceCollection services)
100100
services.TryAddTransient<DatabaseSearchService>();
101101
services.TryAddTransient<FileStorageService>();
102102
services.TryAddTransient<MirrorService>();
103-
services.TryAddTransient<MirrorV2Client>();
104-
services.TryAddTransient<MirrorV3Client>();
103+
services.TryAddTransient<V2UpstreamClient>();
104+
services.TryAddTransient<V3UpstreamClient>();
105105
services.TryAddTransient<DisabledMirrorService>();
106106
services.TryAddSingleton<NullStorageService>();
107107
services.TryAddTransient<PackageDatabase>();
@@ -203,12 +203,12 @@ private static IMirrorService IMirrorServiceFactory(IServiceProvider provider)
203203
return (IMirrorService)provider.GetRequiredService(service);
204204
}
205205

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

211-
return (IMirrorClient)provider.GetRequiredService(service);
211+
return (IUpstreamClient)provider.GetRequiredService(service);
212212
}
213213
}
214214
}

src/BaGet.Core/Mirror/Clients/MirrorV2Client.cs

-155
This file was deleted.

src/BaGet.Core/Mirror/Clients/MirrorV3Client.cs

-63
This file was deleted.

0 commit comments

Comments
 (0)