Fix NATS registration: register BazaarDbContext in AddAiService
AiDeckResolver depends on BazaarDbContext to look up prebuilt decks, but AddAiService never registered it. When NatsMessageRpcResponder.StartAsync called GetServices<IMessageHandler>(), DI failed to instantiate GameAddAiHandler (via AiDeckResolver → BazaarDbContext not found), causing the entire NATS subscription startup to throw — leaving the AI pod with no NATS listeners. Fix: AddBazaarDatabase(configuration) is now called at the top of AddAiService before any handlers are registered. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -13,6 +13,7 @@ using SOR.Ai.Seeding;
|
||||
using SOR.Ai.Training;
|
||||
using SOR.Networking.Abstractions.Messaging;
|
||||
using SOR.Shared;
|
||||
using SOR.Database;
|
||||
using SOR.Database.Contexts;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,6 +27,12 @@ public static class ServiceRegistration
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// ── Database contexts required by AI services ─────────────────────────
|
||||
// AiDeckResolver needs BazaarDbContext to look up prebuilt decks.
|
||||
// Safe to call even when AddBazaarService is also registered on the same host —
|
||||
// EF Core resolves the last AddDbContext registration, and both point to the same DB.
|
||||
services.AddBazaarDatabase(configuration);
|
||||
|
||||
// ── Startup seed (one-shot IHostedService) ────────────────────────────
|
||||
// Ensures AI accounts exist in the DB before traffic is accepted.
|
||||
services.AddHostedService<AiSeedStartupService>();
|
||||
|
||||
Reference in New Issue
Block a user