[backend/federation] Don't retry deliver jobs that returned a client error (except for HTTP 429)
This commit is contained in:
parent
bfc3140381
commit
d5a5a3d464
2 changed files with 21 additions and 1 deletions
19
Iceshrimp.Backend/Core/Extensions/HttpResponseExtensions.cs
Normal file
19
Iceshrimp.Backend/Core/Extensions/HttpResponseExtensions.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Net;
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Extensions;
|
||||
|
||||
public static class HttpResponseExtensions
|
||||
{
|
||||
public static bool IsClientError(this HttpResponseMessage res)
|
||||
=> res.StatusCode is >= HttpStatusCode.BadRequest and <= (HttpStatusCode)499;
|
||||
|
||||
public static bool IsRetryableClientError(this HttpResponseMessage res)
|
||||
=> res.StatusCode is HttpStatusCode.TooManyRequests;
|
||||
|
||||
public static void EnsureSuccessStatusCode(this HttpResponseMessage res, bool excludeClientErrors)
|
||||
{
|
||||
if (excludeClientErrors && res.IsClientError() && !res.IsRetryableClientError())
|
||||
return;
|
||||
res.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Extensions;
|
||||
using Iceshrimp.Backend.Core.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
||||
|
@ -53,7 +54,7 @@ public class DeliverQueue(int parallelism)
|
|||
(int)response.StatusCode, !response.IsSuccessStatusCode);
|
||||
});
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
response.EnsureSuccessStatusCode(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue