mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add some vertical slices to Infrastructure org
This commit is contained in:
parent
9eb27bd787
commit
3722b30624
4 changed files with 42 additions and 21 deletions
|
|
@ -4,10 +4,10 @@
|
|||
using CommandLine;
|
||||
using FilterLists.Agent.AppSettings;
|
||||
using FilterLists.Agent.Core;
|
||||
using FilterLists.Agent.Core.List;
|
||||
using FilterLists.Agent.Infrastructure.Disk;
|
||||
using FilterLists.Agent.Infrastructure.FilterListsApi;
|
||||
using FilterLists.Agent.Infrastructure.GitHub;
|
||||
using LibGit2Sharp;
|
||||
using FilterLists.Agent.Infrastructure.Web;
|
||||
using MediatR;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -89,23 +89,5 @@ private static void AddUrlRepository(this IServiceCollection services)
|
|||
b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests)
|
||||
.WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3)));
|
||||
}
|
||||
|
||||
private static void AddListRepository(this IServiceCollection services)
|
||||
{
|
||||
services.AddHttpClient<IListRepository, ListRepository>().AddTransientHttpErrorPolicy(b =>
|
||||
b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests)
|
||||
.WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3)));
|
||||
}
|
||||
|
||||
private static void AddArchiveRepository(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IRepository, Repository>(s =>
|
||||
{
|
||||
var archiveSettings = s.GetService<IOptions<ArchiveSettings>>().Value;
|
||||
if (!Repository.IsValid(archiveSettings.RepositoryDirectory))
|
||||
Repository.Init(archiveSettings.RepositoryDirectory);
|
||||
return new Repository(archiveSettings.RepositoryDirectory);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using FilterLists.Agent.AppSettings;
|
||||
using LibGit2Sharp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FilterLists.Agent.Infrastructure.Disk
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddArchiveRepository(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IRepository, Repository>(s =>
|
||||
{
|
||||
var archiveSettings = s.GetService<IOptions<ArchiveSettings>>().Value;
|
||||
if (!Repository.IsValid(archiveSettings.RepositoryDirectory))
|
||||
Repository.Init(archiveSettings.RepositoryDirectory);
|
||||
return new Repository(archiveSettings.RepositoryDirectory);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FilterLists.Agent.Infrastructure
|
||||
namespace FilterLists.Agent.Infrastructure.Web
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListRepository : IListRepository
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using FilterLists.Agent.Core.List;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Polly;
|
||||
|
||||
namespace FilterLists.Agent.Infrastructure.Web
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddListRepository(this IServiceCollection services)
|
||||
{
|
||||
services.AddHttpClient<IListRepository, ListRepository>().AddTransientHttpErrorPolicy(b =>
|
||||
b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests)
|
||||
.WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue