Phase 6 (Stufe 2): Core-EF-Repos + umschaltbare Registrierung
- EF-Implementierungen hinter den Core-Interfaces: EfAccountRepository, EfMarketRepository, EfPositionRepository, EfTradeLogRepository. Thread-safe via IDbContextFactory<CoreDbContext> (kurzlebiger Context je Operation). - AddCorePersistence(DatabaseOptions): Provider "MySql" -> EF + DbContextFactory, "Mongo" -> Mongo-Repos. Program.cs uebergibt die aufgeloesten Optionen. - appsettings.json Provider-Default = "Mongo" (App bleibt vorerst auf MongoDB, kein Verhaltenswechsel). MySQL-Connection liegt in gitignorierter appsettings.Local.json. - Build 0 Fehler. Naechste Stufen: Modul-Context + EF-Repos (inkl. trackers/mt_history), Config-Migration Mongo->MySQL, dann Provider umschalten + Mongo entfernen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ad9bb684d4
commit
d8cfdbf6be
+8
-1
@@ -34,6 +34,13 @@ internal static class Program
|
||||
|
||||
AppHost = Host.CreateDefaultBuilder().ConfigureServices(delegate(HostBuilderContext context, IServiceCollection services)
|
||||
{
|
||||
var databaseOptions = new DatabaseOptions
|
||||
{
|
||||
Provider = context.Configuration["Database:Provider"] ?? "Mongo",
|
||||
MySqlConnectionString = context.Configuration["Database:MySqlConnectionString"] ?? string.Empty,
|
||||
ConnectionString = context.Configuration["Database:ConnectionString"] ?? "mongodb://localhost:27017",
|
||||
DatabaseName = context.Configuration["Database:DatabaseName"] ?? "PolyTraderDB"
|
||||
};
|
||||
services.Configure<DatabaseOptions>(context.Configuration.GetSection(DatabaseOptions.SectionName));
|
||||
services.AddSingleton<IMongoDatabase>((IServiceProvider sp) =>
|
||||
{
|
||||
@@ -41,7 +48,7 @@ internal static class Program
|
||||
var client = new MongoClient(dbOptions.ConnectionString);
|
||||
return client.GetDatabase(dbOptions.DatabaseName);
|
||||
});
|
||||
services.AddCorePersistence();
|
||||
services.AddCorePersistence(databaseOptions);
|
||||
services.AddSingleton<IBlockchainWssClientFactory, AlchemyWssClientFactory>();
|
||||
services.AddSingleton((IServiceProvider sp) => ServerSettings.Load("server_settings.xml"));
|
||||
services.AddSingleton<TradingState>();
|
||||
|
||||
Reference in New Issue
Block a user