use a more realistic network delay simulation
parent
255a77456f
commit
a4b55f5f3a
|
@ -7,6 +7,17 @@ using Podcast.Infrastructure.Data.Models;
|
||||||
|
|
||||||
namespace Podcast.Infrastructure.Http.Feeds;
|
namespace Podcast.Infrastructure.Http.Feeds;
|
||||||
|
|
||||||
|
public class JitterHandler : DelegatingHandler
|
||||||
|
{
|
||||||
|
protected override async Task<HttpResponseMessage> 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
|
public class FeedClient : IFeedClient
|
||||||
{
|
{
|
||||||
private static readonly XmlSerializer XmlSerializer = new(typeof(Rss));
|
private static readonly XmlSerializer XmlSerializer = new(typeof(Rss));
|
||||||
|
|
|
@ -17,7 +17,7 @@ var connectionString = builder.Configuration.GetConnectionString("PodcastDb")!;
|
||||||
builder.Services.AddSqlServer<PodcastDbContext>(connectionString);
|
builder.Services.AddSqlServer<PodcastDbContext>(connectionString);
|
||||||
var queueConnectionString = builder.Configuration.GetConnectionString("FeedQueue");
|
var queueConnectionString = builder.Configuration.GetConnectionString("FeedQueue");
|
||||||
builder.Services.AddSingleton(new QueueClient(queueConnectionString, "feed-queue"));
|
builder.Services.AddSingleton(new QueueClient(queueConnectionString, "feed-queue"));
|
||||||
builder.Services.AddHttpClient<IFeedClient, FeedClient>();
|
builder.Services.AddHttpClient<IFeedClient, FeedClient>().AddHttpMessageHandler<JitterHandler>();
|
||||||
|
|
||||||
// Authentication and authorization-related services
|
// Authentication and authorization-related services
|
||||||
builder.Services.AddAuthentication().AddJwtBearer();
|
builder.Services.AddAuthentication().AddJwtBearer();
|
||||||
|
|
Loading…
Reference in New Issue