feat: add quant engine WBS verification harness
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using FastEndpoints;
|
||||
using Hangfire;
|
||||
using QuantEngine.Application.Interfaces;
|
||||
using QuantEngine.Core.Interfaces;
|
||||
|
||||
namespace QuantEngine.Web.Endpoints;
|
||||
@@ -214,20 +216,52 @@ public class GetLatestSnapshotsEndpoint : Endpoint<GetLatestSnapshotsRequest, Ge
|
||||
}
|
||||
}
|
||||
|
||||
public class StartCollectionRunEndpoint : EndpointWithoutRequest
|
||||
public class StartCollectionRunResponse
|
||||
{
|
||||
public string RunId { get; set; } = "";
|
||||
}
|
||||
|
||||
public class StartCollectionRunEndpoint : EndpointWithoutRequest<StartCollectionRunResponse>
|
||||
{
|
||||
private readonly IBackgroundJobClient _jobClient;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<StartCollectionRunEndpoint> _logger;
|
||||
|
||||
public StartCollectionRunEndpoint(
|
||||
IBackgroundJobClient jobClient,
|
||||
IConfiguration configuration,
|
||||
ILogger<StartCollectionRunEndpoint> logger)
|
||||
{
|
||||
_jobClient = jobClient;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/collection/run");
|
||||
AllowAnonymous();
|
||||
Description(d => d
|
||||
.Produces(202)
|
||||
.Produces<StartCollectionRunResponse>(202)
|
||||
.Produces(500));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
// Return 202 Accepted status code via generic status code handler
|
||||
await SendResultAsync(Microsoft.AspNetCore.Http.Results.Accepted());
|
||||
try
|
||||
{
|
||||
var runId = $"api-{DateTime.Now:yyyyMMdd-HHmmss}";
|
||||
var accountMode = _configuration["Kis:AccountMode"] ?? "mock";
|
||||
var tickers = new[] { "005930", "000660", "051910", "005380", "010140", "005490" }.ToList();
|
||||
|
||||
_jobClient.Enqueue<ICollectionOrchestrator>(o => o.RunCollectionAsync(runId, accountMode, tickers));
|
||||
|
||||
_logger.LogInformation("Collection run {RunId} enqueued", runId);
|
||||
|
||||
await SendAsync(new StartCollectionRunResponse { RunId = runId }, 202, ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await SendErrorsAsync(500, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user