Add flagsmith

This commit is contained in:
2025-12-11 19:22:54 +07:00
parent 65d00c0b9a
commit 35df25915f
6 changed files with 187 additions and 2 deletions

View File

@@ -1,7 +1,8 @@
using System.Net;
using System.Net;
using System.Reflection;
using Discord.Commands;
using Discord.WebSocket;
using Flagsmith;
using FluentValidation;
using Managing.Application;
using Managing.Application.Abstractions;
@@ -395,6 +396,7 @@ public static class ApiBootstrap
services.AddScoped<ISynthPredictionService, SynthPredictionService>();
services.AddScoped<ISynthApiClient, SynthApiClient>();
services.AddScoped<IPricesService, PricesService>();
services.AddScoped<IFlagsmithService, FlagsmithService>();
services.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
services.AddTransient<ICommandHandler<OpenSpotPositionRequest, Position>, OpenSpotPositionCommandHandler>();
services.AddTransient<ICommandHandler<CloseBacktestFuturesPositionCommand, Position>, CloseBacktestFuturesPositionCommandHandler>();
@@ -436,6 +438,24 @@ public static class ApiBootstrap
sp.GetRequiredService<IOptions<InfluxDbSettings>>().Value);
services.Configure<KaigenSettings>(configuration.GetSection("Kaigen"));
services.Configure<FlagsmithSettings>(configuration.GetSection("Flagsmith"));
// Flagsmith - Register client as Singleton
services.AddSingleton<FlagsmithClient>(sp =>
{
var settings = sp.GetRequiredService<IOptions<FlagsmithSettings>>().Value;
if (string.IsNullOrWhiteSpace(settings.ApiKey))
{
throw new InvalidOperationException("Flagsmith ApiKey is not configured. Please set the Flagsmith:ApiKey configuration value.");
}
if (string.IsNullOrWhiteSpace(settings.ApiUrl))
{
throw new InvalidOperationException("Flagsmith ApiUrl is not configured. Please set the Flagsmith:ApiUrl configuration value.");
}
return new FlagsmithClient(settings.ApiKey, settings.ApiUrl);
});
// Evm
services.AddGbcFeed();