Initial split migration
This commit is contained in:
@@ -3,42 +3,43 @@ using Elastic.Extensions.Logging.Options;
|
||||
using Elastic.Transport;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Pushy.Components;
|
||||
using Pushy.Grains;
|
||||
using Pushy.Domain;
|
||||
using StackExchange.Redis;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.UseOrleans(silo =>
|
||||
{
|
||||
silo.UseLocalhostClustering();
|
||||
silo.UseRedisReminderService(conf =>
|
||||
{
|
||||
ConfigurationOptions configurationOptions =
|
||||
ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey")!);
|
||||
configurationOptions.DefaultDatabase = 0;
|
||||
conf.ConfigurationOptions = configurationOptions;
|
||||
});
|
||||
|
||||
silo.AddRedisGrainStorageAsDefault(options =>
|
||||
{
|
||||
ConfigurationOptions configurationOptions = ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey")!);
|
||||
configurationOptions.DefaultDatabase = 1;
|
||||
options.ConfigurationOptions = configurationOptions;
|
||||
});
|
||||
string? connectionString = builder.Configuration.GetConnectionString("Valkey");
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
throw new InvalidOperationException("Missing Valkey connection string");
|
||||
|
||||
builder.UseOrleansClient(silo =>
|
||||
{
|
||||
silo.UseRedisClustering(connectionString);
|
||||
silo.AddActivityPropagation();
|
||||
});
|
||||
|
||||
|
||||
if (builder.Environment.IsProduction())
|
||||
{
|
||||
IConnectionMultiplexer multiplexer = ConnectionMultiplexer.Connect(builder.Configuration.GetConnectionString("Valkey")!);
|
||||
string? elasticRawUrl = builder.Configuration["Elasticsearch:Url"];
|
||||
string? elasticApiKey = builder.Configuration["Elasticsearch:ApiKey"];
|
||||
|
||||
if (string.IsNullOrEmpty(elasticRawUrl))
|
||||
throw new InvalidOperationException(
|
||||
"Missing Elasticsearch URL for logging");
|
||||
|
||||
if(string.IsNullOrEmpty(elasticApiKey))
|
||||
throw new InvalidOperationException("Missing Elasticsearch API key");
|
||||
|
||||
IConnectionMultiplexer multiplexer = ConnectionMultiplexer.Connect(connectionString);
|
||||
builder.Services.AddDataProtection()
|
||||
.PersistKeysToStackExchangeRedis(multiplexer);
|
||||
|
||||
var transport = new TransportConfiguration(new StaticNodePool([new Uri("https://elastic-node-1.home.local:9200")]))
|
||||
.Authentication(new ApiKey(builder.Configuration["Elasticsearch:ApiKey"]!))
|
||||
.ServerCertificateValidationCallback((_, _, _, _) => true);
|
||||
|
||||
var transport = new TransportConfiguration(new StaticNodePool([new Uri(elasticRawUrl)]))
|
||||
{
|
||||
Authentication = new ApiKey(elasticApiKey),
|
||||
ServerCertificateValidationCallback = (_, _, _, _) => true
|
||||
};
|
||||
|
||||
builder.Logging.AddElasticsearch(opt =>
|
||||
{
|
||||
@@ -52,15 +53,16 @@ if (builder.Environment.IsProduction())
|
||||
}
|
||||
|
||||
builder.Services.AddScoped(service =>
|
||||
service.GetRequiredService<IGrainFactory>().GetGrain<ILinkGenerator>(Guid.Empty));
|
||||
service.GetRequiredService<IClusterClient>().GetGrain<ILinkGenerator>(Guid.Empty)
|
||||
);
|
||||
builder.Services.AddAllElasticApm();
|
||||
|
||||
builder.Services.AddHealthChecks();
|
||||
builder.Services.AddCors(policy =>
|
||||
{
|
||||
policy.AddDefaultPolicy(builder =>
|
||||
policy.AddDefaultPolicy(cors =>
|
||||
{
|
||||
builder.WithOrigins("https://henrikml.dk")
|
||||
cors.WithOrigins("https://henrikml.dk")
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user