diff --git a/src/Services/Podcasts/Podcast.Infrastructure/Http/Feeds/FeedClient.cs b/src/Services/Podcasts/Podcast.Infrastructure/Http/Feeds/FeedClient.cs index 854ddd5..6c6515e 100644 --- a/src/Services/Podcasts/Podcast.Infrastructure/Http/Feeds/FeedClient.cs +++ b/src/Services/Podcasts/Podcast.Infrastructure/Http/Feeds/FeedClient.cs @@ -7,6 +7,17 @@ using Podcast.Infrastructure.Data.Models; namespace Podcast.Infrastructure.Http.Feeds; +public class JitterHandler : DelegatingHandler +{ + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + // Who would do such a thing?! + // TODO fix this horrible perf leak! + await Task.Delay(TimeSpan.FromSeconds(Random.Shared.NextInt64())); + return await base.SendAsync(request, cancellationToken); + } +} + public class FeedClient : IFeedClient { private static readonly XmlSerializer XmlSerializer = new(typeof(Rss)); diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Program.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Program.cs index 639ac0a..4a55b6a 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Program.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Program.cs @@ -17,7 +17,7 @@ var connectionString = builder.Configuration.GetConnectionString("PodcastDb")!; builder.Services.AddSqlServer(connectionString); var queueConnectionString = builder.Configuration.GetConnectionString("FeedQueue"); builder.Services.AddSingleton(new QueueClient(queueConnectionString, "feed-queue")); -builder.Services.AddHttpClient(); +builder.Services.AddHttpClient().AddHttpMessageHandler(); // Authentication and authorization-related services builder.Services.AddAuthentication().AddJwtBearer();