Skip to content

Commit 2dca5f4

Browse files
committed
doc(IntegrationEvent): update documentation
1 parent 93869bf commit 2dca5f4

File tree

2 files changed

+50
-10
lines changed

2 files changed

+50
-10
lines changed

src/Dispatcher/Masa.Contrib.Dispatcher.IntegrationEvents/README.md

+28-8
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,42 @@
44

55
Example:
66

7-
```C#
7+
``` C#
88
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents //Use cross-process
99
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.Dapr //For example, use dapr to provide pub and sub capabilities, or you can choose other implementations by yourself
10-
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF //Record cross-process message logs
1110
Install-Package Masa.Contrib.Data.UoW.EF //Use UnitOfWork
1211
Install-Package Masa.Contrib.Data.EntityFrameworkCore.SqlServer // Use SqlServer
1312
```
1413

1514
1. Add IIntegrationEventBus
1615

17-
```C#
16+
1.1 Specify the local message service
17+
18+
``` C#
1819
builder.Services
19-
.AddIntegrationEventBus<IntegrationEventLogService>(options=>
20+
.AddIntegrationEventBus<CustomizeIntegrationEventLogService>(options=>
21+
{
22+
options.UseDapr();//Use Dapr to provide pub/sub capabilities, or you can choose other
23+
options.UseUoW<CatalogDbContext>(dbOptions => dbOptions.UseSqlServer("server=localhost;uid=sa;pwd=P@ssw0rd;database=identity"))//Use unit of work, recommended;
24+
});
25+
```
26+
27+
> CustomizeIntegrationEventLogService (custom local message service) needs to inherit IIntegrationEventLogService, and the parameters in the constructor must support getting from CI
28+
29+
1.2 Use the provided EF version of the local message service
30+
31+
Install `Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF`
32+
33+
``` C#
34+
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF //Record cross-process message log
35+
```
36+
37+
``` C#
38+
builder.Services
39+
.AddIntegrationEventBus(options=>
2040
{
2141
options.UseDapr();//Use Dapr to provide pub/sub capabilities, or you can choose other
22-
options.UseUoW<CatalogDbContext>(dbOptions => dbOptions.UseSqlServer("server=localhost;uid=sa;pwd=P@ssw0rd;database=identity"))
42+
options.UseUoW<CatalogDbContext>(dbOptions => dbOptions.UseSqlServer("server=localhost;uid=sa;pwd=P@ssw0rd;database=identity"))//Use unit of work, recommended
2343
.UseEventLog<CatalogDbContext>();
2444
});
2545
```
@@ -28,7 +48,7 @@ builder.Services
2848
2949
2. Custom IntegrationEvent
3050

31-
```C#
51+
``` C#
3252
public class DemoIntegrationEvent : IntegrationEvent
3353
{
3454
public override string Topic { get; set; } = nameof(DemoIntegrationEvent);//dapr topic name
@@ -39,7 +59,7 @@ public class DemoIntegrationEvent : IntegrationEvent
3959

4060
3. Custom CustomDbContext
4161

42-
```C#
62+
``` C#
4363
public class CustomDbContext : MasaDbContext
4464
{
4565
public DbSet<User> Users { get; set; } = null!;
@@ -53,7 +73,7 @@ public class CustomDbContext : MasaDbContext
5373

5474
4. Send Event
5575

56-
```C#
76+
``` C#
5777
IIntegrationEventBus eventBus;//Get IIntegrationEventBus through DI
5878
await eventBus.PublishAsync(new DemoIntegrationEvent());//Send cross-process events
5979
```

src/Dispatcher/Masa.Contrib.Dispatcher.IntegrationEvents/README.zh-CN.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,36 @@
77
```C#
88
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents //使用跨进程事件
99
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.Dapr //例如使用dapr提供pub、sub能力,也可自行选择其他实现
10-
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF //记录跨进程消息日志
1110
Install-Package Masa.Contrib.Data.UoW.EF //使用工作单元
1211
Install-Package Masa.Contrib.Data.EntityFrameworkCore.SqlServer // 使用SqlServer
1312
```
1413

1514
1. 添加IIntegrationEventBus
1615

16+
1.1 指定本地消息服务
17+
1718
```C#
1819
builder.Services
19-
.AddIntegrationEventBus<IntegrationEventLogService>(options=>
20+
.AddIntegrationEventBus<CustomizeIntegrationEventLogService>(options=>
21+
{
22+
options.UseDapr();//使用Dapr提供pub/sub能力,也可以自行选择其他的
23+
options.UseUoW<CatalogDbContext>(dbOptions => dbOptions.UseSqlServer("server=localhost;uid=sa;pwd=P@ssw0rd;database=identity"))//使用工作单元,推荐使用;
24+
});
25+
```
26+
27+
> CustomizeIntegrationEventLogService(自定义本地消息服务)需继承IIntegrationEventLogService,并且构造函数中的参数必须支持从CI获取
28+
29+
1.2 使用提供的EF版的本地消息服务
30+
31+
安装`Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF`
32+
33+
``` C#
34+
Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF //记录跨进程消息日志
35+
```
36+
37+
```C#
38+
builder.Services
39+
.AddIntegrationEventBus(options=>
2040
{
2141
options.UseDapr();//使用Dapr提供pub/sub能力,也可以自行选择其他的
2242
options.UseUoW<CatalogDbContext>(dbOptions => dbOptions.UseSqlServer("server=localhost;uid=sa;pwd=P@ssw0rd;database=identity"))//使用工作单元,推荐使用

0 commit comments

Comments
 (0)