Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对配置文件面向开发者做的可读性,便利性处理 #278

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions Blog.Core.Api/Blog.Core.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

<PropertyGroup>
<SaveMergeLog>true</SaveMergeLog>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\Blog.Core.Api\Blog.Core.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
Expand All @@ -22,6 +26,7 @@
</PropertyGroup>
<PropertyGroup>
<ServerGarbageCollection>false</ServerGarbageCollection>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Extensions\**" />
Expand Down Expand Up @@ -51,6 +56,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Easy.Tool.MergeJson" Version="1.0.0" />
<PackageReference Include="log4mongo-netcore" Version="3.2.0" />
<PackageReference Include="MicroKnights.Log4NetAdoNetAppender" Version="2.2.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
//apollo 配置
"Apollo": {
"Enable": false,
Expand Down
40 changes: 40 additions & 0 deletions Blog.Core.Api/CustomConfig/AppSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"AppSettings": {
"RedisCachingAOP": {
"Enabled": false
},
"MemoryCachingAOP": {
"Enabled": true
},
"LogAOP": {
"Enabled": true,
"LogToFile": {
"Enabled": false
},
"LogToDB": {
"Enabled": true
}
},
"TranAOP": {
"Enabled": true
},
"SqlAOP": {
"Enabled": true,
"LogToFile": {
"Enabled": false
},
"LogToDB": {
"Enabled": false
},
"LogToConsole": {
"Enabled": true
}
},
"Date": "2018-08-28",
"SeedDBEnabled": true, //只生成表结构
"SeedDBDataEnabled": true, //生成表,并初始化数据
"Author": "Blog.Core",
"SvcName": "", // /svc/blog
"UseLoadTest": false
}
}
8 changes: 8 additions & 0 deletions Blog.Core.Api/CustomConfig/Audience.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Audience": {
"Secret": "sdfsdfsrty45634kkhllghtdgdfss345t678fs", //不要太短,16位+
"SecretFile": "C:\\my-file\\blog.core.audience.secret.txt", //安全。内容就是Secret
"Issuer": "Blog.Core",
"Audience": "wr"
}
}
9 changes: 9 additions & 0 deletions Blog.Core.Api/CustomConfig/ConsulSetting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ConsulSetting": {
"ServiceName": "BlogCoreService",
"ServiceIP": "localhost",
"ServicePort": "9291",
"ServiceHealthCheck": "/healthcheck",
"ConsulAddress": "http://localhost:8500"
}
}
80 changes: 80 additions & 0 deletions Blog.Core.Api/CustomConfig/Db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
// 请配置MainDB为你想要的主库的ConnId值,并设置对应的Enabled为true;
// *** 单库操作,把 MutiDBEnabled 设为false ***;
// *** 多库操作,把 MutiDBEnabled 设为true,其他的从库Enabled也为true **;
// 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6

"MainDB": "WMBLOG_SQLITE", //当前项目的主库,所对应的连接字符串的Enabled必须为true
"MutiDBEnabled": false, //是否开启多库模式
"CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer
"DBS": [
/*
对应下边的 DBType
MySql = 0,
SqlServer = 1,
Sqlite = 2,
Oracle = 3,
PostgreSQL = 4,
Dm = 5,//达梦
Kdbndp = 6,//人大金仓
*/
{
"ConnId": "WMBLOG_SQLITE",
"DBType": 2,
"Enabled": true,
"HitRate": 50, // 值越大,优先级越高
"Connection": "WMBlog.db" //sqlite只写数据库名就行
},
{
"ConnId": "WMBLOG_MSSQL_1",
"DBType": 1,
"Enabled": false,
"HitRate": 40,
"Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_1;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"ProviderName": "System.Data.SqlClient"
},
{
"ConnId": "WMBLOG_MSSQL_2",
"DBType": 1,
"Enabled": false,
"HitRate": 30,
"Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"ProviderName": "System.Data.SqlClient"
},
{
"ConnId": "WMBLOG_MYSQL",
"DBType": 0,
"Enabled": false,
"HitRate": 20,
"Connection": "server=.;Database=ddd;Uid=root;Pwd=123456;Port=10060;Allow User Variables=True;"
},
{
"ConnId": "WMBLOG_MYSQL_2",
"DBType": 0,
"Enabled": true,
"HitRate": 20,
"Connection": "server=localhost;Database=blogcore001;Uid=root;Pwd=root;Port=3306;Allow User Variables=True;"
},
{
"ConnId": "WMBLOG_ORACLE",
"DBType": 3,
"Enabled": false,
"HitRate": 10,
"Connection": "Data Source=127.0.0.1/ops;User ID=OPS;Password=123456;Persist Security Info=True;Connection Timeout=60;"
},
{
"ConnId": "WMBLOG_DM",
"DBType": 5,
"Enabled": false,
"HitRate": 10,
"Connection": "PORT=5236;DATABASE=DAMENG;HOST=localhost;PASSWORD=SYSDBA;USER ID=SYSDBA;"
},
{
"ConnId": "WMBLOG_KDBNDP",
"DBType": 6,
"Enabled": true,
"HitRate": 10,
"Connection": "Server=127.0.0.1;Port=54321;UID=SYSTEM;PWD=system;database=SQLSUGAR4XTEST1;"
}
]
}
6 changes: 6 additions & 0 deletions Blog.Core.Api/CustomConfig/EventBus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"EventBus": {
"Enabled": false,
"SubscriptionClientName": "Blog.Core"
}
}
40 changes: 40 additions & 0 deletions Blog.Core.Api/CustomConfig/IpRateLimiting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"IpRateLimiting": {
"EnableEndpointRateLimiting": true, //False: globally executed, true: executed for each
"StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter
"RealIpHeader": "X-Real-IP",
"ClientIdHeader": "X-ClientId",
"IpWhitelist": [], //白名单
"EndpointWhitelist": [ "get:/api/xxx", "*:/api/yyy" ],
"ClientWhitelist": [ "dev-client-1", "dev-client-2" ],
"QuotaExceededResponse": {
"Content": "{{\"status\":429,\"msg\":\"访问过于频繁,请稍后重试\",\"success\":false}}",
"ContentType": "application/json",
"StatusCode": 429
},
"HttpStatusCode": 429, //返回状态码
"GeneralRules": [ //api规则,结尾一定要带*
{
"Endpoint": "*:/api/blog*",
"Period": "1m",
"Limit": 20
},
{
"Endpoint": "*/api/*",
"Period": "1s",
"Limit": 3
},
{
"Endpoint": "*/api/*",
"Period": "1m",
"Limit": 30
},
{
"Endpoint": "*/api/*",
"Period": "12h",
"Limit": 500
}
]

}
}
9 changes: 9 additions & 0 deletions Blog.Core.Api/CustomConfig/Kafka.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Kafka": {
"Enabled": false,
"Servers": "localhost:9092",
"Topic": "blog",
"GroupId": "blog-consumer",
"NumPartitions": 3 //主题分区数量
}
}
12 changes: 12 additions & 0 deletions Blog.Core.Api/CustomConfig/LogFiedOutPut.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"LogFiedOutPutConfigs": {
"tcpAddressHost": "", // 输出elk的tcp连接地址
"tcpAddressPort": 0, // 输出elk的tcp端口号
"ConfigsInfo": [ // 配置的输出elk节点内容 常用语动态标识
{
"FiedName": "applicationName",
"FiedValue": "Blog.Core.Api"
}
]
}
}
47 changes: 47 additions & 0 deletions Blog.Core.Api/CustomConfig/Middleware.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"Middleware": {
"RequestResponseLog": {
"Enabled": true,
"LogToFile": {
"Enabled": false
},
"LogToDB": {
"Enabled": true
}
},
"IPLog": {
"Enabled": true,
"LogToFile": {
"Enabled": false
},
"LogToDB": {
"Enabled": true
}
},
"RecordAccessLogs": {
"Enabled": true,
"LogToFile": {
"Enabled": false
},
"LogToDB": {
"Enabled": true
},
"IgnoreApis": "/api/permission/getnavigationbar,/api/monitor/getids4users,/api/monitor/getaccesslogs,/api/monitor/server,/api/monitor/getactiveusers,/api/monitor/server,"
},
"SignalR": {
"Enabled": false
},
"SignalRSendLog": {
"Enabled": false
},
"QuartzNetJob": {
"Enabled": true
},
"Consul": {
"Enabled": false
},
"IpRateLimit": {
"Enabled": true
}
}
}
6 changes: 6 additions & 0 deletions Blog.Core.Api/CustomConfig/Mongo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Mongo": {
"ConnectionString": "mongodb://nosql.data",
"Database": "BlogCoreDb"
}
}
11 changes: 11 additions & 0 deletions Blog.Core.Api/CustomConfig/Nacos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"nacos": {
"ServerAddresses": [ "http://localhost:8848" ], // nacos 连接地址
"DefaultTimeOut": 15000, // 默认超时时间
"Namespace": "public", // 命名空间
"ListenInterval": 10000, // 监听的频率
"ServiceName": "blog.Core.Api", // 服务名
"Port": "9291", // 服务端口号
"RegisterEnabled": true // 是否直接注册nacos
}
}
11 changes: 11 additions & 0 deletions Blog.Core.Api/CustomConfig/Pay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"PayInfo": { //建行聚合支付信息
"MERCHANTID": "", //商户号
"POSID": "", //柜台号
"BRANCHID": "", //分行号
"pubKey": "", //公钥
"USER_ID": "", //操作员号
"PASSWORD": "", //密码
"OutAddress": "http://127.0.0.1:12345" //外联地址
}
}
9 changes: 9 additions & 0 deletions Blog.Core.Api/CustomConfig/RabbitMQ.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"RabbitMQ": {
"Enabled": false,
"Connection": "118.25.251.13",
"UserName": "",
"Password": "!",
"RetryCount": 3
}
}
5 changes: 5 additions & 0 deletions Blog.Core.Api/CustomConfig/Redis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Redis": {
"ConnectionString": "127.0.0.1:6319,password=admin"
}
}
36 changes: 36 additions & 0 deletions Blog.Core.Api/CustomConfig/Startup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Startup": {
"Domain": "http://localhost:9291",
"Cors": {
"PolicyName": "CorsIpAccess", //策略名称
"EnableAllIPs": false, //当为true时,开放所有IP均可访问。
// 支持多个域名端口,注意端口号后不要带/斜杆:比如localhost:8000/,是错的
// 注意,http://127.0.0.1:1818 和 http://localhost:1818 是不一样的
"IPs": "http://127.0.0.1:2364,http://localhost:2364,http://127.0.0.1:6688,http://localhost:6688"
},
"AppConfigAlert": {
"Enabled": true
},
"ApiName": "Blog.Core",
"IdentityServer4": {
"Enabled": false, // 这里默认是false,表示使用jwt,如果设置为true,则表示系统使用Ids4模式
"AuthorizationUrl": "http://localhost:5004", // 认证中心域名
"ApiName": "blog.core.api" // 资源服务器
},
"Authing": {
"Enabled": false,
"Issuer": "https://uldr24esx31h-demo.authing.cn/oidc",
"Audience": "63d51c4205c2849803be5178",
"JwksUri": "https://uldr24esx31h-demo.authing.cn/oidc/.well-known/jwks.json"
},
"RedisMq": {
"Enabled": false //redis 消息队列
},
"MiniProfiler": {
"Enabled": false //性能分析开启
},
"Nacos": {
"Enabled": false //Nacos注册中心
}
}
}
18 changes: 18 additions & 0 deletions Blog.Core.Api/DevelopmentCustomConfig/Apollo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
//apollo 配置
"Apollo": {
"Enable": false,
"Config": {
"AppId": "blog.core",
"Env": "DEV",
"MetaServer": "http://localhost:8080/",
"ConfigServer": [ "http://localhost:8080/" ]
},
"Namespaces": [ //Namespaces的数据格式Properties,Xml,Json,Yml,Yaml,Txt
{
"Name": "test",
"Format": "json"
}
]
}
}
Loading