CUB-33: integrate Moonraker filament usage polling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Net.Http.Headers;
|
||||
using Extrudex.API.Filters;
|
||||
using Extrudex.API.Hubs;
|
||||
using Extrudex.Domain.Interfaces;
|
||||
@@ -50,6 +51,23 @@ builder.Services.AddSwaggerGen(c =>
|
||||
// ── QR Code Generation ──────────────────────────────────────
|
||||
builder.Services.AddSingleton<IQrCodeService, QrCodeService>();
|
||||
|
||||
// ── Filament Usage Service ──────────────────────────────────
|
||||
builder.Services.AddScoped<IFilamentUsageService, FilamentUsageService>();
|
||||
|
||||
// ── Moonraker Client ───────────────────────────────────────
|
||||
// Named HttpClient for Moonraker API calls with configurable timeout.
|
||||
// Poller timeout is driven by MoonrakerPollerOptions.RequestTimeout.
|
||||
builder.Services.AddHttpClient<IMoonrakerClient, MoonrakerClient>(client =>
|
||||
{
|
||||
client.DefaultRequestHeaders.Accept.Add(
|
||||
new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
});
|
||||
|
||||
// ── Moonraker Usage Poller (Background Service) ─────────────
|
||||
builder.Services.Configure<MoonrakerPollerOptions>(
|
||||
builder.Configuration.GetSection("MoonrakerPoller"));
|
||||
builder.Services.AddHostedService<MoonrakerUsagePoller>();
|
||||
|
||||
// ── FluentValidation ──────────────────────────────────────
|
||||
// Registers all validators from the API assembly into DI.
|
||||
builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
|
||||
Reference in New Issue
Block a user