Add resilient upload queue and client health
This commit is contained in:
@@ -38,17 +38,31 @@ internal sealed class N8nUploadClient
|
||||
request.Headers.Add("X-ATN-Payload-SHA256", payloadHash);
|
||||
request.Headers.Add("X-ATN-Signature", signature);
|
||||
|
||||
using HttpResponseMessage response = httpClient.Send(request);
|
||||
string responseText = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
|
||||
return new UploadResult
|
||||
try
|
||||
{
|
||||
Success = response.IsSuccessStatusCode,
|
||||
StatusCode = (int)response.StatusCode,
|
||||
Message = string.IsNullOrWhiteSpace(responseText) ? response.ReasonPhrase ?? string.Empty : responseText,
|
||||
Nonce = nonce,
|
||||
PayloadSha256 = payloadHash
|
||||
};
|
||||
using HttpResponseMessage response = httpClient.Send(request);
|
||||
string responseText = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
|
||||
return new UploadResult
|
||||
{
|
||||
Success = response.IsSuccessStatusCode,
|
||||
StatusCode = (int)response.StatusCode,
|
||||
Message = string.IsNullOrWhiteSpace(responseText) ? response.ReasonPhrase ?? string.Empty : responseText,
|
||||
Nonce = nonce,
|
||||
PayloadSha256 = payloadHash
|
||||
};
|
||||
}
|
||||
catch (Exception exception) when (exception is HttpRequestException or TaskCanceledException)
|
||||
{
|
||||
return new UploadResult
|
||||
{
|
||||
Success = false,
|
||||
StatusCode = 0,
|
||||
Message = exception.Message,
|
||||
Nonce = nonce,
|
||||
PayloadSha256 = payloadHash
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static string ComputeSha256(string value)
|
||||
|
||||
Reference in New Issue
Block a user