Browse Source

docs: 添加分布式事件文档

pull/95/head
王军 3 years ago
parent
commit
1b93341884
  1. 1
      docs/content/index.md
  2. 46
      docs/content/user-guide/zh/infrastructure/cap.md
  3. 80
      docs/content/user-guide/zh/infrastructure/config.md
  4. 1
      docs/mkdocs.yml

1
docs/content/index.md

@ -31,6 +31,7 @@ Title: Abp Vnext Pro
- [x] Setting 管理
- [x] 多租户
- [x] 文件管理
- [x] 多语言管理
![](https://blog-resouce.oss-cn-shenzhen.aliyuncs.com/images/abp/4.4/4.4login.png)
![](https://blog-resouce.oss-cn-shenzhen.aliyuncs.com/images/abp/01.png)

46
docs/content/user-guide/zh/infrastructure/cap.md

@ -0,0 +1,46 @@
## dotnetcore.cap
分布式事件总线系统允许发布和订阅跨应用/服务边界传输的事件. 你可以使用分布式事件总线在微服务或应用程序之间异步发送和接收消息.
### 安装
- 添加以下 NuGet 包到你的项目
- Lion.AbpPro.CAP
- Lion.AbpPro.CAP.EntityFrameworkCore
- DotNetCore.CAP.MySql (如果是其它数据库,请安装对应类型)
- DotNetCore.CAP.RabbitMQ (如果是其它中间件,请安装对应类型)
- 添加 [DependsOn(typeof(LionAbpProCapEntityFrameworkCoreModule))] 到你的项目模块类.
## 配置
Mysql,和 RabbitMq 为例
```csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.AddAbpCap(capOptions =>
{
// 指定数据数据库连接字符串
capOptions.SetCapDbConnectionString(configuration["ConnectionStrings:Default"]);
capOptions.UseEntityFramework<AbpProDbContext>();
// 使用rabbitmq,配置host,username,password
capOptions.UseRabbitMQ(option =>
{
option.HostName = configuration.GetValue<string>("Cap:RabbitMq:HostName");
option.UserName = configuration.GetValue<string>("Cap:RabbitMq:UserName");
option.Password = configuration.GetValue<string>("Cap:RabbitMq:Password");
});
var hostingEnvironment = context.Services.GetHostingEnvironment();
bool auth = !hostingEnvironment.IsDevelopment();
// 启用面板
capOptions.UseDashboard(options =>
{
options.UseAuth = auth;
options.AuthorizationPolicy = LionAbpProCapPermissions.CapManagement.Cap;
});
});
}
```
- 即可使用 Abp vNext 标准写法,发送分布式事件和订阅事件

80
docs/content/user-guide/zh/infrastructure/config.md

@ -14,63 +14,65 @@
],
"MinimumLevel": {
// 默认全局日志级别
"Default": "Information",
"Override": {
//名称空间为 Microsoft 日志级别
"Microsoft": "Information",
//名称空间为 Volo.Abp 日志级别
"Volo.Abp": "Information",
"Default": "Information",
"Override": {
//名称空间为 Microsoft 日志级别
"Microsoft": "Information",
//名称空间为 Volo.Abp 日志级别
"Volo.Abp": "Information",
//名称空间为 Hangfire 日志级别
"Hangfire": "Information",
//名称空间为 DotNetCore.CAP 日志级别
"DotNetCore.CAP": "Information",
"Hangfire": "Information",
//名称空间为 DotNetCore.CAP 日志级别
"DotNetCore.CAP": "Information",
//名称空间为 Serilog.AspNetCore 日志级别
"Serilog.AspNetCore": "Information",
"Serilog.AspNetCore": "Information",
//名称空间为 Microsoft.EntityFrameworkCore 日志级别
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning",
//名称空间为 Microsoft.AspNetCore 日志级别
"Microsoft.AspNetCore": "Information"
"Microsoft.AspNetCore": "Information"
}
},
"WriteTo": [
{
// 输出到控制台日志
"Name": "Console"
"Name": "Console"
},
{
// 输出到文件
"Name": "File",
"Name": "File",
"Args": {
"path": "logs/logs-.txt",
// 按天输出
"rollingInterval": "Day"
"rollingInterval": "Day"
}
}
]
}
```
### 写入ES
!!! WARNING "先决条件:搭建好ES环境"
### 写入 ES
!!! WARNING "先决条件:搭建好 ES 环境"
- Enabled:是否启用
- Url:es地址
- IndexFormat:es索引
- Url:es 地址
- IndexFormat:es 索引
- UserName:用户名
- Password:密码
- SearchIndexFormat:es日志查询索引模式
- SearchIndexFormat:es 日志查询索引模式
```json
"ElasticSearch": {
"Enabled": "false",
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Enabled": "false",
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"SearchIndexFormat": "Lion.AbpPro.development*"
"SearchIndexFormat": "Lion.AbpPro.development*"
},
```
- 查看Lion.AbpPro.HttpApi.Host.Program.cs
- 查看 Lion.AbpPro.HttpApi.Host.Program.cs
```csharp
public class Program
@ -78,7 +80,7 @@ public class Program
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
@ -97,16 +99,17 @@ public class Program
}
```
## 跨域(CORS)
- 允许指定策略
```json
"App": {
// 逗号分隔
"CorsOrigins": "http://*.com,http://localhost:4200"
},
```
- 配置跨域
```csharp
@ -140,27 +143,12 @@ private void ConfigureCors(ServiceConfigurationContext context)
- Issuer:签发主体
- SecurityKey:密钥
- ExpirationTime:过期时间(单位小时)
```json
"Jwt": {
"Audience": "Lion.AbpPro",
"Audience": "Lion.AbpPro",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
"Issuer": "Lion.AbpPro",
"Issuer": "Lion.AbpPro",
"ExpirationTime": 30
}
```
## CAP
!!! WARNING "如果要切换其他中间件请参考 [dotnetcore.cap](https://cap.dotnetcore.xyz/)"
- Enabled: 是否启用
- RabbitMq:Mq配置
```json
"Cap": {
"Enabled": "true",
"RabbitMq": {
"HostName": "localhost",
"UserName": "admin",
"Password": "admin"
}
}
```

1
docs/mkdocs.yml

@ -78,6 +78,7 @@ nav:
- 配置: user-guide/zh/infrastructure/config.md
- 前端: user-guide/zh/infrastructure/frontend.md
- FreeSql: user-guide/zh/infrastructure/freesql.md
- 分布式事件: user-guide/zh/infrastructure/cap.md
- 应用模块:
- 基础模块: user-guide/zh/modules/basic.md
- 设置(Setting): user-guide/zh/modules/setting.md

Loading…
Cancel
Save