refactor(backend): use single shared HTTP client with backoff

This commit is contained in:
sam 2025-03-11 16:10:55 +01:00
parent bba322bd22
commit 5d452824cd
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
9 changed files with 232 additions and 75 deletions

View file

@ -27,6 +27,7 @@ using NodaTime.Text;
namespace Foxnouns.Backend.Jobs;
public class CreateDataExportJob(
HttpClient client,
DatabaseContext db,
IClock clock,
UserRendererService userRenderer,
@ -36,7 +37,6 @@ public class CreateDataExportJob(
ILogger logger
)
{
private static readonly HttpClient Client = new();
private readonly ILogger _logger = logger.ForContext<CreateDataExportJob>();
public static void Enqueue(Snowflake userId)
@ -201,7 +201,7 @@ public class CreateDataExportJob(
if (s3Path == null)
return;
HttpResponseMessage resp = await Client.GetAsync(s3Path);
HttpResponseMessage resp = await client.GetAsync(s3Path);
if (resp.StatusCode != HttpStatusCode.OK)
{
_logger.Warning("S3 path {S3Path} returned a non-200 status, not saving file", s3Path);