[backend/federation] Don't mark client error deliver jobs as successful
This commit is contained in:
parent
d5a5a3d464
commit
583e954106
2 changed files with 12 additions and 4 deletions
|
@ -10,10 +10,12 @@ public static class HttpResponseExtensions
|
|||
public static bool IsRetryableClientError(this HttpResponseMessage res)
|
||||
=> res.StatusCode is HttpStatusCode.TooManyRequests;
|
||||
|
||||
public static void EnsureSuccessStatusCode(this HttpResponseMessage res, bool excludeClientErrors)
|
||||
public static void EnsureSuccessStatusCode(
|
||||
this HttpResponseMessage res, bool excludeClientErrors, Func<Exception> exceptionFactory
|
||||
)
|
||||
{
|
||||
if (excludeClientErrors && res.IsClientError() && !res.IsRetryableClientError())
|
||||
return;
|
||||
throw exceptionFactory();
|
||||
res.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
using System.Net;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Extensions;
|
||||
|
@ -54,9 +55,9 @@ public class DeliverQueue(int parallelism)
|
|||
(int)response.StatusCode, !response.IsSuccessStatusCode);
|
||||
});
|
||||
|
||||
response.EnsureSuccessStatusCode(true);
|
||||
response.EnsureSuccessStatusCode(true, () => new ClientError(response.StatusCode));
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception e) when (e is not ClientError)
|
||||
{
|
||||
if (job.RetryCount++ < 10)
|
||||
{
|
||||
|
@ -81,6 +82,11 @@ public class DeliverQueue(int parallelism)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientError(HttpStatusCode statusCode) : Exception
|
||||
{
|
||||
public HttpStatusCode StatusCode => statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
public class DeliverJobData
|
||||
|
|
Loading…
Add table
Reference in a new issue