almost ready
This commit is contained in:
@@ -2,10 +2,7 @@ using BlueLaminate.Core.Listings;
|
||||
using BlueLaminate.Core.Options;
|
||||
using BlueLaminate.Core.Skins;
|
||||
using BlueLaminate.EFCore.DependencyInjection;
|
||||
using BlueLaminate.Scraper.Browser;
|
||||
using BlueLaminate.Scraper.CsFloat;
|
||||
using BlueLaminate.Scraper.CsMoney;
|
||||
using BlueLaminate.Scraper.Proxies;
|
||||
using BlueLaminate.Scraper.Skins;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -54,8 +51,6 @@ public static class ServiceCollectionExtensions
|
||||
.Bind(configuration.GetSection(SkinCatalogOptions.SectionName));
|
||||
services.AddOptions<SweepOptions>()
|
||||
.Bind(configuration.GetSection(SweepOptions.SectionName));
|
||||
services.AddOptions<CsMoneyOptions>()
|
||||
.Bind(configuration.GetSection(CsMoneyOptions.SectionName));
|
||||
|
||||
// Typed-handler pooling via IHttpClientFactory; clients are scoped so a
|
||||
// command's handler and the service it drives share one instance (and thus
|
||||
@@ -72,42 +67,12 @@ public static class ServiceCollectionExtensions
|
||||
sp.GetRequiredService<IHttpClientFactory>().CreateClient(CatalogHttpClient),
|
||||
sp.GetRequiredService<IOptions<SkinCatalogOptions>>().Value));
|
||||
|
||||
// Residential proxy provider (IPRoyal). Credentials come from configuration
|
||||
// — IPROYAL_USERNAME / IPROYAL_PASSWORD env vars in practice. Resolution
|
||||
// throws a clear error only when a proxy-using command actually needs it, so
|
||||
// API-only commands (sync, fetch) run without proxy creds configured.
|
||||
services.AddSingleton<IProxyProvider>(sp =>
|
||||
{
|
||||
var username = configuration["IPROYAL_USERNAME"];
|
||||
var password = configuration["IPROYAL_PASSWORD"];
|
||||
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"IPRoyal credentials are not configured. Set IPROYAL_USERNAME and "
|
||||
+ "IPROYAL_PASSWORD (env vars or user secrets) before running a proxy command.");
|
||||
}
|
||||
|
||||
return new IpRoyalProxyProvider(username, password);
|
||||
});
|
||||
|
||||
// cs.money is driven through a real, non-headless browser (Selenium/Edge,
|
||||
// zero CDP) routed through a local forwarding proxy that chains to the
|
||||
// residential gateway, not an HttpClient.
|
||||
services.AddSingleton<LocalForwardingProxyFactory>();
|
||||
services.AddScoped<BrowserDriverFactory>();
|
||||
services.AddScoped<ProxyProbe>();
|
||||
services.AddScoped(sp => new CsMoneyCaptureService(
|
||||
sp.GetRequiredService<IProxyProvider>(),
|
||||
sp.GetRequiredService<LocalForwardingProxyFactory>(),
|
||||
sp.GetRequiredService<BrowserDriverFactory>(),
|
||||
sp.GetRequiredService<IOptions<CsMoneyOptions>>().Value,
|
||||
sp.GetRequiredService<ILogger<CsMoneyCaptureService>>()));
|
||||
|
||||
// Application services (constructor injection; DbContext keeps them scoped).
|
||||
services.AddScoped<ListingSweepService>();
|
||||
services.AddScoped<SkinSyncService>();
|
||||
services.AddScoped<CsMoney.CsMoneyIngestService>();
|
||||
services.AddScoped<CsMoney.MarketPresenceService>();
|
||||
services.AddScoped<SkinLand.SkinLandIngestService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user