add compile & test worker

This commit is contained in:
prixod
2025-10-24 23:46:51 +04:00
parent 3d854c3470
commit 6cead15a5f
19 changed files with 849 additions and 13 deletions

View File

@@ -0,0 +1,39 @@
using System.Text;
using System.Text.Json;
using LiquidCode.Tester.Common.Models;
namespace LiquidCode.Tester.Worker.Services;
public class CallbackService : ICallbackService
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILogger<CallbackService> _logger;
public CallbackService(IHttpClientFactory httpClientFactory, ILogger<CallbackService> logger)
{
_httpClientFactory = httpClientFactory;
_logger = logger;
}
public async Task SendStatusAsync(string callbackUrl, TesterResponseModel response)
{
_logger.LogInformation("Sending status update to {CallbackUrl} for submit {SubmitId}", callbackUrl, response.SubmitId);
try
{
var httpClient = _httpClientFactory.CreateClient();
var json = JsonSerializer.Serialize(response);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PostAsync(callbackUrl, content);
httpResponse.EnsureSuccessStatusCode();
_logger.LogInformation("Status update sent successfully");
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to send status update to {CallbackUrl}", callbackUrl);
// Don't throw - callback failures shouldn't stop testing
}
}
}