Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor improvements - move Rabbit settings to the new class (changes in App_Settings)

supportad6dd3b19aaa
diff --git a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
index 741c6ec2e..f41159bf4 100644
--- a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
@@ -222,12 +222,5 @@ namespace Grand.Infrastructure.Configuration
/// </summary>
public bool UseSerilogRequestLogging { get; set; }
- public bool RabbitEnabled { get; set; }
- public bool RabbitCachePubSubEnabled { get; set; }
- public string RabbitHostName { get; set; }
- public string RabbitVirtualHost { get; set; }
- public string RabbitUsername { get; set; }
- public string RabbitPassword { get; set; }
- public string RabbitCacheReceiveEndpoint { get; set; }
}
}
diff --git a/src/Core/Grand.Infrastructure/Configuration/RabbitConfig.cs b/src/Core/Grand.Infrastructure/Configuration/RabbitConfig.cs
new file mode 100644
index 000000000..e8b97e96e
--- /dev/null
+++ b/src/Core/Grand.Infrastructure/Configuration/RabbitConfig.cs
@@ -0,0 +1,13 @@
+namespace Grand.Infrastructure.Configuration
+{
+ public partial class RabbitConfig
+ {
+ public bool RabbitEnabled { get; set; }
+ public bool RabbitCachePubSubEnabled { get; set; }
+ public string RabbitHostName { get; set; }
+ public string RabbitVirtualHost { get; set; }
+ public string RabbitUsername { get; set; }
+ public string RabbitPassword { get; set; }
+ public string RabbitCacheReceiveEndpoint { get; set; }
+ }
+}
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 5d6be3152..861f1a356 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -149,8 +149,8 @@ namespace Grand.Infrastructure
/// <param name="services"></param>
private static void AddMassTransitRabbitMq(IServiceCollection services, IConfiguration configuration, AppTypeSearcher typeSearcher)
{
- var config = new AppConfig();
- configuration.GetSection("Application").Bind(config);
+ var config = new RabbitConfig();
+ configuration.GetSection("Rabbit").Bind(config);
if (!config.RabbitEnabled) return;
services.AddMassTransit(x =>
@@ -193,6 +193,7 @@ namespace Grand.Infrastructure
var config = services.StartupConfig<AppConfig>(configuration.GetSection("Application"));
services.StartupConfig<HostingConfig>(configuration.GetSection("Hosting"));
services.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));
+ services.StartupConfig<RabbitConfig>(configuration.GetSection("Rabbit"));
services.StartupConfig<ApiConfig>(configuration.GetSection("Api"));
services.StartupConfig<GrandWebApiConfig>(configuration.GetSection("GrandWebApi"));
services.StartupConfig<LiteDbConfig>(configuration.GetSection("LiteDb"));
diff --git a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
index c6daecd67..136f469a7 100644
--- a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
@@ -69,9 +69,9 @@ namespace Grand.Web.Common.Startup
serviceCollection.AddSingleton<ICacheBase, RedisMessageCacheManager>();
return;
}
- var application = new AppConfig();
- configuration.GetSection("Application").Bind(config);
- if (application.RabbitCachePubSubEnabled && application.RabbitEnabled)
+ var rabbit = new RabbitConfig();
+ configuration.GetSection("Rabbit").Bind(rabbit);
+ if (rabbit.RabbitCachePubSubEnabled && rabbit.RabbitEnabled)
{
serviceCollection.AddSingleton<ICacheBase, RabbitMqMessageCacheManager>();
}
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 735dee7b8..ec16491a0 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -79,17 +79,6 @@
"AmazonDistributionDomainName": "", //Domain name for cloudfront distribution
- //Enable RabbitMq
- "RabbitEnabled": false,
- "RabbitCachePubSubEnabled": false,
- "RabbitHostName": "localhost",
- "RabbitVirtualHost": "/",
- "RabbitUsername": "guest",
- "RabbitPassword": "guest",
- //must be unique for each instance
- "RabbitCacheReceiveEndpoint": "grandnode",
-
-
//For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/
//https://github.com/dotnet/roslyn/wiki/Roslyn-Overview
"UseRoslynScripts": false,
@@ -147,7 +136,7 @@
//(Serilog) Request logging - The package includes middleware for smarter HTTP request logging.
"UseSerilogRequestLogging": false
},
-
+
"Redis": {
///Enable the Publish/Subscribe messaging with redis to manage memory cache on every server
"RedisPubSubEnabled": false,
@@ -157,6 +146,18 @@
"PersistKeysToRedisUrl": "127.0.0.1:6379,allowAdmin=true,defaultDatabase=1"
},
+ "Rabbit": {
+ //Enable RabbitMq
+ "RabbitEnabled": false,
+ "RabbitCachePubSubEnabled": false,
+ "RabbitHostName": "localhost",
+ "RabbitVirtualHost": "/",
+ "RabbitUsername": "guest",
+ "RabbitPassword": "guest",
+ //must be unique for each instance
+ "RabbitCacheReceiveEndpoint": "grandnode"
+ },
+
"FacebookSettings": {
//Facebook-assigned App ID
"AppId": "",
@@ -168,54 +169,54 @@
"ClientSecret": ""
},
"LiteDb": {
- //This setting is required to use LiteDB database
- "UseLiteDb": false,
- //LiteDB database as a singleton service in the application
- "Singleton": true,
- //Init connection string - it's required only for the installation process!
- "LiteDbConnectionString": "Filename=App_Data/database.db"
- },
-
- //access to the api to web controllers
- "GrandWebApi": {
- "Enabled": false,
- "SecretKey": "your private secret key", //at least 16 characters
- "ValidateIssuer": false,
- "ValidIssuer": "",
- "ValidateAudience": false,
- "ValidAudience": "",
- "ValidateLifetime": true,
- "ValidateIssuerSigningKey": true,
- "ExpiryInMinutes": 1440,
- "RefreshTokenExpiryInMinutes": 1440
- },
- //api for admin
- "Api": {
- "Enabled": false,
- "UseSwagger": false,
- "SecretKey": "your private secret key", //at least 16 characters
- "ValidateIssuer": false,
- "ValidIssuer": "",
- "ValidateAudience": false,
- "ValidAudience": "",
- "ValidateLifetime": true,
- "ValidateIssuerSigningKey": true,
- "ExpiryInMinutes": 1440,
- //generate system model
- "SystemModel": true
- },
- "Serilog": {
- "Using": [ "Serilog.Sinks.File" ]
- //,
- //"MinimumLevel": {
- // "Default": "Warning"
- // }
- //,
- //"WriteTo": [
- // {
- // "Name": "File",
- // "Args": { "path": "logs/log.txt" }
- // }
- // ]
- }
- }
\ No newline at end of file
+ //This setting is required to use LiteDB database
+ "UseLiteDb": false,
+ //LiteDB database as a singleton service in the application
+ "Singleton": true,
+ //Init connection string - it's required only for the installation process!
+ "LiteDbConnectionString": "Filename=App_Data/database.db"
+ },
+
+ //access to the api to web controllers
+ "GrandWebApi": {
+ "Enabled": false,
+ "SecretKey": "your private secret key", //at least 16 characters
+ "ValidateIssuer": false,
+ "ValidIssuer": "",
+ "ValidateAudience": false,
+ "ValidAudience": "",
+ "ValidateLifetime": true,
+ "ValidateIssuerSigningKey": true,
+ "ExpiryInMinutes": 1440,
+ "RefreshTokenExpiryInMinutes": 1440
+ },
+ //api for admin
+ "Api": {
+ "Enabled": false,
+ "UseSwagger": false,
+ "SecretKey": "your private secret key", //at least 16 characters
+ "ValidateIssuer": false,
+ "ValidIssuer": "",
+ "ValidateAudience": false,
+ "ValidAudience": "",
+ "ValidateLifetime": true,
+ "ValidateIssuerSigningKey": true,
+ "ExpiryInMinutes": 1440,
+ //generate system model
+ "SystemModel": true
+ },
+ "Serilog": {
+ "Using": [ "Serilog.Sinks.File" ]
+ //,
+ //"MinimumLevel": {
+ // "Default": "Warning"
+ // }
+ //,
+ //"WriteTo": [
+ // {
+ // "Name": "File",
+ // "Args": { "path": "logs/log.txt" }
+ // }
+ // ]
+ }
+}
\ No newline at end of file