Skip to content

Commit

Permalink
feat: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
mixhsnhd committed Dec 25, 2024
1 parent 761e07f commit 61ea2c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions src/EoaServer.Silo/Extensions/OrleansHostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@ namespace EoaServer.Silo.Extensions;

public static class OrleansHostExtensions
{
public static IHostBuilder UseOrleans(this IHostBuilder hostBuilder)
public static IHostBuilder UseOrleansSnapshot(this IHostBuilder hostBuilder)
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
var configSection = configuration.GetSection("Orleans");
if (configSection == null)
throw new ArgumentNullException(nameof(configSection), "The OrleansServer node is missing");
return hostBuilder.UseOrleans(siloBuilder =>
return hostBuilder.UseOrleans((context, siloBuilder) =>
{
if (configSection.GetValue<bool>("IsRunningInKubernetes"))
//Configure OrleansSnapshot
var orleansConfigSection = context.Configuration.GetSection("Orleans");
var isRunningInKubernetes = orleansConfigSection.GetValue<bool>("IsRunningInKubernetes");
if (isRunningInKubernetes)
{
Log.Warning("==Use kubernetes hosting...");
UseKubernetesHostClustering(siloBuilder, configSection);
UseKubernetesHostClustering(siloBuilder, orleansConfigSection);
Log.Warning("==Use kubernetes hosting end...");
}
else
{
Log.Warning("==Use docker hosting...");
UseDockerHostClustering(siloBuilder, configSection);
UseDockerHostClustering(siloBuilder, orleansConfigSection);
Log.Warning("==Use docker hosting end...");
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/EoaServer.Silo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>
.ConfigureServices((hostcontext, services) =>
{
services.AddApplication<EoaServerOrleansSiloModule>(); })
.UseOrleans()
.UseOrleansSnapshot()
.UseAutofac()
.UseSerilog();
}
2 changes: 1 addition & 1 deletion src/EoaServer.Silo/appsettings.apollo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"Timeout": 5000,
"StartupTimeout": 30000
},
"IsApolloEnabled": false
"IsApolloEnabled": true
}
2 changes: 1 addition & 1 deletion src/EoaServer.Silo/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Orleans": {
"IsRunningInKubernetes": false,
"IsRunningInKubernetes": true,
"ClusterId": "EoaServerSiloCluster",
"ServiceId": "EoaServerOrleansBasicService",
"AdvertisedIP": "127.0.0.1",
Expand Down

0 comments on commit 61ea2c8

Please sign in to comment.